Guest User

Untitled

a guest
Jan 17th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. my code
  2. -------
  3. Public Function AuthenticateUser(ByVal ldapServerName As String, ByVal username As String, ByVal password As String) As Boolean
  4. Dim ou_ As String = "sunbs.in"
  5. Dim _ldapServerName = ldapServerName
  6.  
  7. Dim oRoot As DirectoryEntry = New DirectoryEntry("LDAP://" & ldapServerName &
  8. "/uid=""" & username & """,ou= ou_", "uid=""" & username & """,ou= ou_", password, AuthenticationTypes.ServerBind)
  9.  
  10. Dim oSearcher As DirectorySearcher = New DirectorySearcher(oRoot)
  11.  
  12. Try
  13.  
  14. Dim mySearchResult As SearchResult = oSearcher.FindOne()
  15.  
  16. Return True
  17.  
  18.  
  19. Catch e As Exception
  20.  
  21. MsgBox("Error is " & e.Message)
  22.  
  23. Return False
  24.  
  25. End Try
  26.  
  27. End Function
Add Comment
Please, Sign In to add comment