T
teejayem
Hi.
I have searched the groups and have been unable to find an answer to
my question.
I am trying to reset the password of a user account in active
directory.
I have been trying to do this using the following code:-
Private Sub ResetPassword(ByVal User As String, ByVal NewPassword
As String)
Dim objUser As DirectoryServices.DirectoryEntry
Dim strDomain As String
strDomain = GetDomainName()
objUser = New DirectoryServices.DirectoryEntry("WinNT://" &
strDomain & "/" & User & ",User")
Dim objPassword As Object() = {NewPassword}
objUser.Invoke("SetPassword", objPassword)
objUser.CommitChanges()
objUser.Close()
objUser.Dispose()
End Sub
Private Function GetDomainName() As String
Return System.Environment.UserDomainName
End Function
I do not get any errors but it doesn't work.
Can anyone see where i am going wrong?
The computer i am running the application on is a member of a server
2003 active directory domain and is a member of the Administrators
group.
Any help is much appreciated.
Cheers,
Tom.
I have searched the groups and have been unable to find an answer to
my question.
I am trying to reset the password of a user account in active
directory.
I have been trying to do this using the following code:-
Private Sub ResetPassword(ByVal User As String, ByVal NewPassword
As String)
Dim objUser As DirectoryServices.DirectoryEntry
Dim strDomain As String
strDomain = GetDomainName()
objUser = New DirectoryServices.DirectoryEntry("WinNT://" &
strDomain & "/" & User & ",User")
Dim objPassword As Object() = {NewPassword}
objUser.Invoke("SetPassword", objPassword)
objUser.CommitChanges()
objUser.Close()
objUser.Dispose()
End Sub
Private Function GetDomainName() As String
Return System.Environment.UserDomainName
End Function
I do not get any errors but it doesn't work.
Can anyone see where i am going wrong?
The computer i am running the application on is a member of a server
2003 active directory domain and is a member of the Administrators
group.
Any help is much appreciated.
Cheers,
Tom.