Home > database >  How to use LDAP in pb
How to use LDAP in pb

Time:09-22

Every brother, who use PB had LDAP authentication? Like the little information online, so I said, thank you.

CodePudding user response:

PB can go up by ole, can refer to the following code

Sub 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
  • Related