web application, get group name - active directory
I want to access to a special group in active directory but with this function I could just that a special user is exist in active directory or not, I mean I want to see that a user is exist in special group which I myself specified. could anyone help me and change this code to which could do what I want.
Public Function ValidateUser(ByVal Domain As String, ByVal username As String, ByVal password As String) As Boolean
Dim dehelp As String
dehelp = "LDAP://"
Dim de As New DirectoryEntry(dehelp & Domain, username, password, AuthenticationTypes.Secure)
Dim srch As New DirectorySearcher(de)
'srch.Filter = "(objectClass=Group)"
srch.Filter = "(&(objectClass=user)(samAccountName=" & username & "))"
Dim result As SearchResult = srch.FindOne
'Dim obj As DirectoryEntry
If Not result Is Nothing Then
'obj = result.GetDirectoryEntry()
Catch ex As Exception
Console.Write(ex.Message + ControlChars.NewLine + ex.StackTrace)