473,387 Members | 1,812 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,387 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 16 '05 #1
1 1337
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 16 '05 #2

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: Toufani | last post by:
Hi everybody, I want to retrieve information about objects in active directory windows 2000 and their properties. I got some codes that don't work absolutely. for example I can't retrieve users...
3
by: Luis Esteban Valencia | last post by:
Hello gusys, Is it possible to make my asp.net application add users to the AD , I also want to be able to delete users, modify their information, everything through a website. Thanks for the...
1
by: tangus via DotNetMonster.com | last post by:
Hello all, I'm really struggling with getting some Active Directory code to work in ASP.NET. Can you please provide assistance? I am executing the following code: Dim enTry As DirectoryEntry =...
8
by: Brian Henry | last post by:
Hello, I know it is possible to have deployable applications during login of win2k and win xp systems through active directory, but i was wondering if it is possible to create a deployment...
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...
2
by: P Webster | last post by:
We recently moved a web site that validated user credentials in Active Directory from IIS 5.1 to IIS 6, and the validation code no longer works. The web.config file is set to Windows authentication...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
0
by: bcanter | last post by:
I found a file on the web that will allow you to enumerate groups but it was an .hta and the top level admins won't allow this. I need to give managers access to the groups so that when a new user is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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,...

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.