Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to create a new Active Directory user, Invoke("SetPassword",pwd) throws "The RPC server is unavailable"
    primarykey
    data
    text
    <p>I'm trying to create a new user on my development active directory server using .NET System.DirectoryServices namespace.</p> <p>I try using the following code:</p> <pre><code>DirectoryEntry dirEntry = new DirectoryEntry(path, "TESTDOM\\Administrator", "2109password", AuthenticationTypes.Secure | AuthenticationTypes.ServerBind); object o = dirEntry.NativeObject; DirectoryEntry newUser = dirEntry.Children.Add("CN=NewUser4", "user"); newUser.Properties["samAccountName"].Value = "NewUser4"; newUser.Properties["Description"].Add("User Description"); newUser.Invoke("SetPassword", new object[] {"2109password"} ); newUser.CommitChanges(); </code></pre> <p>I also tried committing using</p> <pre><code>newUser.CommitChanges(); </code></pre> <p>before I call the Invoke to set the password. I always get a TargetInvocationException wrapping:</p> <pre><code>InnerException {"The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)"} System.Exception {System.Runtime.InteropServices.COMException} </code></pre> <p>The exception is always only thrown when I call </p> <pre><code>newUser.Invoke("SetPassword", new object[] {"2109password"} ); </code></pre> <p>If I call newUser.CommitChanges() before I try to call Invoke with SetPassword, the new user is created on the domain. I can then go manually to the AD machine and set the same password with no problems (so it's not a problem with the password string being against the rules). I've notice many post online about this but found no solution.</p> <p>I think it might have something to do with the fact that the machine running the code is not a member in the domain. Although the user TESTDOM\Administrator is a member of the: administrators, domain admins, schema admin and enterprise admins groups on the TESTDOM domain.</p> <p>Notice that I can't use System.DirectoryServices.AccountManagement namespace as I'm working with .NET 2 Any ideas on what can I do to solve this? I am desperate </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload