Setting password through directory services

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

TheNewUser.Invoke("SetPassword", New Object() {"123"})

Does anyone have any idea why that call wouldn't work, even though I have
supplied credentials which are fully capable of setting and changing a
password manually? (through an administrative acct)
In the program I just get done making a user and modifying its properties
(which works great) and then I commit changes. I then try to set the
password. An exception is thrown, and says the invocation has failed. Also in
the string is network path not found.
Can anyone tell me what I might try to remedy this situation? I have tried a
lot of things, but I feel as if I must be missing something....
(BTW, yes I know I need to use a secure password, but I will implement that
once I can get this simple code to work)
more of the code follows:

Dim TheNewUser As DirectoryEntry

TheNewUser = adentry3.Children.Add("cn=" & txtUserName.Text, "user")
TheNewUser.Properties("SAMAccountName").Value = txtUserName.Text
TheNewUser.Properties("userPrincipalName").Value = txtUserName.Text & "@" &
AD.Properties("dc").Value() & ".com"
 
If your domain security policy requires complex passwords, then you'll get
TargetInvocationException when you try to set the password to "123". You'll
have to supply a password of at least 7 characters that contains upper and
lower case letters and at least one digit.

Cheers,
John Wadie
 
Are you able to add the user successfully to the Active Directory? Probably
the problem is related to the user creation, not to setting the password.
Check Active Directory Users and Computers after running your code, if the
creation is successful you should see the new user added but disabled.

Regards,
John Wadie
 
Yes, the user creation works fine, I am even able to manually enable the
account. I am 100% sure the set password invocation is returning my error.
 
Try changing your line to

TheNewUser.Invoke("SetPassword", "123")

It works for me.

Regards,
John Wadie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top