Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update AD Users

Status
Not open for further replies.

jecairns

Programmer
Oct 5, 2005
21
CA
I am currently trying to allow users to update their AD password online. They authenticate against AD, which works fine, but I am hung up on an error.(below) It seems pretty simple, however the new passwords I am supplying/testing with reach all the requirements.


Code:

Dim user As New DirectoryEntry(_path, domainAndUsername, oldPassword, AuthenticationTypes.Secure And AuthenticationTypes.Sealing)
Dim search As New System.DirectoryServices.DirectorySearcher(user)
search.Filter = ("(samAccountName=" & username & ")")

Dim sr As SearchResult = search.FindOne()

If (Not (sr Is Nothing)) Then
user = sr.GetDirectoryEntry()

'Reset Password
user.Invoke("ChangePassword", New Object() {oldPassword, newPassword}) 'fails here
user.CommitChanges()
End If


Exception:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x800708C5): The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements. (Exception from HRESULT: 0x800708C5) --- End of inner exception stack trace --- at System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args)


Also, this is running on an XP Pro box, if that makes a difference. Any ideas?

Thanks,

JC
 
Hi,
How are you supplying the new password?
Have you confirmed that the exact string you enter is what is being sent?



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
The new password is being supplied from a password textbox. I have just double-checked, and the exact password is being sent.
 
Another side note that I double checked with our Network Admin, and the passwords I am supplying are passing all policy requirements.
 
Hi,
Since the password box masks the actual text, can you determine if the real text is being sent and not just a string of #s ...

[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Sorry for the run-around. Our network admin also informed me that we only allow users to change their passwords once in a 24 hour period - and since this "test" user had it's password reset since then - for me to test - it was causing that issue.

Thanks for your time!!!
 
I had this exact same problem two weeks ago. Never got i to work as it should. I did find a work around, though. Instead of this line:
Code:
user.Invoke("ChangePassword", New Object() {oldPassword, newPassword})
[\code]
I used this:
[code]
user.Invoke("SetPassword", New Object() {newPassword})
[\code]
And it worked like a charm. I did not need to worry about supplying the old password because the user had to login to even get to the change password screen, thus they already had authenticated themselves.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top