473,503 Members | 9,836 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Searching an AD security group

Hi,

When a user visits my site (ASP.NET + VB.NET), I need to know if they are in
a particular AD security group in order to display the pertinant information.

When I call UserLookup in code below it works well at returning whether the
user is directly a member of the group. However, if they are contained inside
of an inherited security group, it returns false because it will not search
recursively.

I thought this would be simple to find information on, but apparently I
thought wrong.

Any help would be appreciated.

CODE:
The class has DOMAINNAMEVALUE, SERVERNAMEVALUE and GROUPNAMEVALUE initalized
in the constructor.

Public Function ReturnUsers()
Dim strDirEntryPath As String
strDirEntryPath = "WinNT://" & DomainNameValue & "/" &
ServerNameValue & "/" & GroupNameValue & ",group"
Dim users As Object

Dim group As New DirectoryEntry(strDirEntryPath)
users = group.Invoke("members")

Dim user1 As Object
Dim UsersCollection As New Collection

For Each user1 In CType(users, IEnumerable)
Try
Dim userEntry As New
System.DirectoryServices.DirectoryEntry(user1)
UsersCollection.Add(userEntry.Name)
Catch e1 As Exception
Return e1
Exit Function
End Try
Next

Return UsersCollection
End Function

'returns true/false if a person is in an AD security group or not
Public Function UserLookup(ByVal user As String)

Dim i As Integer
Dim UsersCollection As New Collection
Dim Match As Boolean = False

Match = CheckUser()

UsersCollection = Me.ReturnUsers

For i = 1 To UsersCollection.Count
If UsersCollection.Item(i) = user Then
Match = True
Return Match
End If
Next

End Function

--
Weeims
Nov 21 '05 #1
3 1635
Hi

Here is sample in CodeProject.
Although it is in C#, but I think VB.NET method is similar.
Authorize and authenticate users with
http://www.codeproject.com/csharp/ActiveDirUsers.asp

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #2
Thanks for your reply Peter,

The code you pointed me to returns the groups that a given member belongs
to. This is somewhat opposite of what I am looking for. I need to be able
to search the members of a group to look for a logged on person. The problem
is inherited groups. The user may belong to a group (gp1) that in turn
belongs to another group (gp2). GP2 does not show as a group that the user
belongs to.

I need to start with GP2, evaluate its members, if one of its members is yet
another security group, then evaluate the members of this group (GP1) and so
on until I either find the user, or run out of paths to dig into.

This is the same process the OS is doing each time I try to open a file,
that is why I firgured this would be well documented.

--
Weeims
""Peter Huang" [MSFT]" wrote:
Hi

Here is sample in CodeProject.
Although it is in C#, but I think VB.NET method is similar.
Authorize and authenticate users with
http://www.codeproject.com/csharp/ActiveDirUsers.asp

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #3
Hi

Here is a link about how to use DirectoryService to list the members of
certain group.(NOTE: it use WINNT, but the LDAP will use the similar
approach except the path string is different).
You may take a look.
http://www.eggheadcafe.com/forums/Fo...=27383&INTID=2

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #4

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

Similar topics

14
5344
by: Ludwig77 | last post by:
I read that there are some tags that can be entered in a web page's meta tags in order to prevent web bot searching and indexing of the web page for search engines. What is the tagging that I...
0
1970
by: Brian Loesgen | last post by:
The next San Diego .Net User Group meeting is Tuesday, November 25, 2003 at the Scripps Ranch Library. Scripps Ranch Library 10301 Scripps Lake Drive San Diego, CA 92131-1026 Please join us...
1
2338
by: Namratha Shah \(Nasha\) | last post by:
Hey Guys, Before we start with our sample app we need to view the security configuration files on the machine. You will find them under <drive>\WInNT\Microsoft.NET\FrameWork\<version>\Config ...
116
7414
by: Mike MacSween | last post by:
S**t for brains strikes again! Why did I do that? When I met the clients and at some point they vaguely asked whether eventually would it be possible to have some people who could read the data...
4
1720
by: Ant | last post by:
I am trying to apply security to a database I have just finished. The application is split into a back end of tables and a front end of forms etc. I need some users to have access to forms based on...
0
1424
by: Mark Broadbent | last post by:
Could someone who has active experience of assigning Security Policys please clarify my follow comments... Having gone through the MSDN documentation on this subject, my condensed version of the...
0
2078
by: Namratha Shah \(Nasha\) | last post by:
Hey Guys, Today we are going to look at Code Access Security. Code access security is a feature of .NET that manages code depending on its trust level. If the CLS trusts the code enough to...
16
2078
by: Marina | last post by:
Hi, I am trying to find the minimum security settings to allow a windows control embedded in IE have full trust. If I give the entire Intranet zone full trust, this works. However, this is...
17
2655
by: TC | last post by:
In the past I always regarded user/group security as fairly tight. It is tricky to implement, but once implemented properly, it can't be cracked except through a dedicated effort. Recently,...
0
7207
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
7095
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7015
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7470
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...
0
5602
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4693
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
403
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.