各位老大,有誰用PB做過LDAP的認證嗎?好像網上的資料很少,有的話幫忙說下,謝謝。
uj5u.com熱心網友回復:
PB可以通過ole去弄,可參照下面的代碼Sub SetPassword()
Try
Dim RootDSE As New DirectoryServices.DirectoryEntry("LDAP://RootDSE")
Dim DomainDN As String = RootDSE.Properties("DefaultNamingContext").Value
Dim ADEntry As New DirectoryServices.DirectoryEntry("LDAP://" & DomainDN)
Dim ADSearch As 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.CommitChanges()
Else
MsgBox("UserFound was not found.")
End If
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/65242.html
標籤:API 調用
