PC Review


Reply
Thread Tools Rate Thread

Active Directory Groups Membership

 
 
=?Utf-8?B?UGVycnl0?=
Guest
Posts: n/a
 
      18th Nov 2005
I need to find out if the user that is logged in (in active directory) is a
member of a certain group?

Please help.

 
Reply With Quote
 
 
 
 
Siva M
Guest
Posts: n/a
 
      19th Nov 2005
Will this help? http://www.codeproject.com/dotnet/us...membership.asp

"Perryt" <(E-Mail Removed)> wrote in message
news:5586D487-E9A3-4C00-90A8-(E-Mail Removed)...
I need to find out if the user that is logged in (in active directory) is a
member of a certain group?

Please help.


 
Reply With Quote
 
Marc Scheuner [MVP ADSI]
Guest
Posts: n/a
 
      21st Nov 2005
>I need to find out if the user that is logged in (in active directory) is a
>member of a certain group?


1) You need to add references to the System.DirectoryServices
namespace and the COM Active Ds Type Library to your project.

2) You can find out what the current user is by using this code:

// get a IADsADSystemInfo object and show it
ActiveDs.IADsADSystemInfo oSysInfo = new ActiveDs.ADSystemInfoClass();
string sCurrentUser = oSysInfo.UserName;

3) Now you can either bind to that user and look at the group he's a
member of, or you can do the reverse - bind to the group and see if
the user is a member of that group.

Given the user, you bind to the user object:

DirectoryEntry deUser = new DirectoryEntry("LDAP://" + sCurrentUser);

// enumerate his groups
foreach(object oGroup in deUser.Properties["memberOf"])
{
string sGroupName = oGroup.ToString();
if(sGroupName == "<your group name>")
{
// do something with that information
}
}


HTH
Marc
================================================================
Marc Scheuner May The Source Be With You!
Berne, Switzerland m.scheuner -at- inova.ch
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Active Directory Group Membership Mark Clark Microsoft VB .NET 0 14th Mar 2008 05:04 PM
Active Directory Domain Membership =?Utf-8?B?cGF1bHN0YW5kaW5n?= Windows Vista Administration 1 15th Jun 2007 03:50 PM
Active Directory - Domain groups - How to get the names and right of users contains in groups ??? Mathew Microsoft Windows 2000 Security 2 22nd Apr 2005 02:56 AM
Active Directory. finding groups of groups RTT Microsoft VB .NET 1 5th Apr 2005 04:34 AM
Membership of user in Active Directory Alvyn Microsoft Windows 2000 Active Directory 10 17th May 2004 02:43 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:18 PM.