hello this is my code could anyone help me, I want to search exact user in special group in active directory, my group name is test11 . could anyone here help me to do this.
thanks this is my code
Public Function ValidateUser(By Val Domain As String, ByVal username As String, ByVal password As String) As Boolean
Dim strGroupDN As String
strGroupDN = "Users"
Try
Dim de As New DirectoryEntry( "LDAP://" & Domain, username, password, AuthenticationT ypes.Secure)
Dim srch As New DirectorySearch er(de)
' srch.Filter = "(objectClass=G roup)"
'srch.SearchSco pe = SearchScope.Sub tree
'srch.Filter = "(&(ou=hh)(cn=t est11))"
srch.Filter = "(&(objectClass =user)(samAccou ntName=" & username & "))"
de.Invoke("Grou ps", New Object() {"test11"})
'srch.Filter = "(&(objectCateg ory=Person)(obj ectClass=user)( ou=hh)"
' srch.Filter = "(&(objectClass =user)(samAccou ntName=" & username & ")(memberOf =" & strGroupDN & "))"
Dim result As SearchResult = srch.FindOne
If Not result Is Nothing Then
Return True
Else
Return False
End If
Catch ex As Exception
Console.Write(e x.Message + ControlChars.Ne wLine + ex.StackTrace)
Return False
End Try
End Function
--------------------------------
From: Sara
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>Q7MXSVHElkK pSsjsO5XMUg==</Id>