CodePudding user response:
PB can go up by ole, can refer to the following codeSub SetPassword ()
Try
Dim RootDSE As New DirectoryServices. DirectoryEntry (" LDAP://RootDSE ")
Dim DomainDN As String=RootDSE. The Properties (" DefaultNamingContext "). The Value
Dim ADEntry As New DirectoryServices. DirectoryEntry (" LDAP://"& amp; DomainDN)
Dim ADSearch As the New System. DirectoryServices. DirectorySearcher (ADEntry)
Dim ADUser As DirectoryServices. DirectoryEntry
ADSearch. Filter=((name="username)")
ADSearch. SearchScope=DirectoryServices. SearchScope. Subtree
Dim UserFound As DirectoryServices. SearchResult=ADSearch. FindOne ()
If Not IsNothing (UserFound) Then
ADUser=UserFound. GetDirectoryEntry ()
ADUser. Invoke (" SetPassword ", "password")
ADUser.Com mitChanges ()
The Else
MsgBox (" UserFound was not found. ")
End the If
Catch the ex As Exception
Console. WriteLine (ex. Message)
End the Try
End Sub