473,398 Members | 2,380 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,398 software developers and data experts.

Active Directory groups

Hi everyone,

I have the following code that basically reads all information about a
domain user.
System.DirectoryServices.DirectoryEntry entry = new
System.DirectoryServices.DirectoryEntry("LDAP://" + dom, "myusername",
"password", AuthenticationTypes.Secure);
System.DirectoryServices.DirectorySearcher mySearcher = new
System.DirectoryServices.DirectorySearcher(entry);

// Change this to search for anything
mySearcher.Filter = ("(sAMAccountName=myusername)");

System.DirectoryServices.SearchResult resEnt = mySearcher.FindOne();
try
{
System.DirectoryServices.DirectoryEntry de=resEnt.GetDirectoryEntry();
Console.WriteLine("Display Name : " +
de.Properties["DisplayName"].Value.ToString());
Console.WriteLine("User Name : " +
de.Properties["sAMAccountName"].Value.ToString());
Console.WriteLine("First Name : " +
de.Properties["GivenName"].Value.ToString());
Console.WriteLine("Last Name : " + de.Properties["sn"].Value.ToString());
Console.WriteLine("Department : " +
de.Properties["Department"].Value.ToString());
}

Does anyone know I can modify this code to view all the groups that a member
falls under?

Thank you
Maziar A.
Nov 15 '05 #1
1 1176
Try this:
private void EnumerateGroups(LDAPpath)

{

DirectoryEntry userAccount = new DirectoryEntry(LDAPpath);

Console.WriteLine("user {0} is a member of:", userAccount.Name);

foreach(string member in user.Properties["memberOf"])

{

Console.WriteLine(member);

}

}

HTH;
Eric Cadwell
http://www.origincontrols.com
Nov 15 '05 #2

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

Similar topics

0
by: Yaseen D M | last post by:
I am list groups of a user from active directory. I get the list but if i remove the user from one of the groups and again list the groups it still includes the groups from the the user was...
4
by: CodeRazor | last post by:
I need to retrieve a list of groups from Active Directory. Then i need to retrieve a list of users from a group. I'm unfamiliar with Active Directory objects. Can i connect to Active Directory...
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 =...
4
by: Patirck Ige | last post by:
Would it be easier to have an intranetsystem built based on some security gruopson Active directory or having to use a Database to have a validation store and Roles. Which way would be the best to...
6
by: varkey.mathew | last post by:
Dear all, Bear with me, a poor newbie(atleast in AD).. I have to authenticate a user ID and password for a user as a valid Active Directory user or not. I have created the IsAuthenticated...
4
by: Patrick.O.Ige | last post by:
If i want to generate a menu structure depending on who is logged in in an intranet system(using windows authentication) is it better to use the GROUPS in Active Directory or to move the Active...
2
by: Jm | last post by:
Hi All Im not sure of which way to go about this so ill start by explaining what im trying to do and the options ive come up with. ok.. I have a client program which talks to an sql server...
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...
2
by: Max Vit | last post by:
I have been toying with the idea of having an Active Directory authentication / authorisation functionality in MS Access; but there is not much useful info around. I have built these...
2
by: rote | last post by:
My sceanrio is this on an asp.net 2.0 freamework. I want to use any of the data controls e.g Gridview,DetailView etc.. But i want some buttons e.g update,edit save etc to be enable or disabled...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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...
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
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
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,...
0
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...

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.