Help me in active directory search for special group in asp.net

S

Sara

Dear Sir,
I want to access to a special group in active directory but with this
function I could just see 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 not in all of active directory. could
you please help me and change this code or show me a method to which
could do what I wanted

thanks

my organization unit is "hh"
my group name is "test11"
--------------------------------------------------

Public Function ValidateUser(ByVal 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, AuthenticationTypes.Secure)
Dim srch As New DirectorySearcher(de)

' srch.Filter = "(objectClass=Group)"
'srch.SearchScope = SearchScope.Subtree
srch.Filter = "(&(ou=hh)(!(ou=builtin)(ou=Users)))"
' srch.Filter =
"(&(objectClass=user)(samAccountName=" & username & ")(ou=hh)"


'srch.Filter =
"(&(objectCategory=Person)(objectClass=user)(ou=hh)"

' srch.Filter = "(&(objectClass=user)(samAccountName=" &
username & ")(memberOf=" & strGroupDN & "))"
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
 
W

Willy Denoyette [MVP]

Why cross-posting instead of posting to the correct NG?

Please, post VB.NET questions to microsoft.public.dotnet.languages.vb.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top