
DirectoryEntry Set User Login Password
I've scoured the net for a VB example that actually works to allow me to set a user password using DirectoryServices. Nothing works! Can anyone help?
The
C# examples don't work for me. I've tried over 20 variations. Help!
Here's some sample code:
Private Sub PutActiveDirectoryPassword()
'This subroutine sets the users login password
'This is coded for a VB Web Form, this is the
' Form.aspx.vb file
Dim ldapUser As DirectoryEntry
Dim strLdapContainer As String
strLdapContainer = "LDAP://CN=Username,_
OU=OUName,DC=SITE1,_
DC=Domain,DC=com"
ldapUser = New DirectoryEntry_
(strLdapContainer ,_
"username", "password", _
AuthenticationTypes.Secure)
Try
ldapUser.Invoke("SetPassword", "password")
Try
ldapUser.CommitChanges()
Catch
Response.Write("Password _
COMMIT failed. Error=" + _
Err.Description.ToString + ".<br>")
End Try
Catch
Response.Write("Password _
SET failed. Error=" + _
Err.Description.ToString + ".<br>")
End Try
End Sub
*** Sent via Developersdex http://www.*-*-*.com/ ***
Don't just participate in USENET...get rewarded for it!