473,405 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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

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
Nov 22 '05 #1
2 3116
Why cross-posting instead of posting to the correct NG?

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

Willy.

"Sara" <ra*****@aut.ac.ir> wrote in message
news:ae*************************@posting.google.co m...
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

Nov 22 '05 #2
Why cross-posting instead of posting to the correct NG?

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

Willy.

"Sara" <ra*****@aut.ac.ir> wrote in message
news:ae*************************@posting.google.co m...
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

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sara | last post by:
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...
1
by: Sara | last post by:
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...
0
by: Sara | last post by:
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...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.