active directory user Authentication problem
I want to access to a special group in active directory but with this function I could just check 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.
thanks
Public Function ValidateUser(ByVal Domain As String, ByVal username As String, ByVal password As String) As Boolean
Dim dehelp As String
dehelp = "LDAP://"
Try
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()
'Response.Write(obj)
Return True
Else
Return False
End If
Catch ex As Exception
Console.Write(ex.Message + ControlChars.NewLine + ex.StackTrace)
Return False
End Try
End Function
Regards
Sara
__________________
Regards
Sara
|