I'm using ASP.net with C# and have a very little idea about Active Directory. I've been given a task to write a program in steps below:
The ASP.net application is given the username of a user.
The application should query all the groups of the user with the given username.
Then the application should display these groups in two separate lists one consisting of the distribution groups and in other list, the rest of the groups.
Now, the querying for all the groups is easy. But how can I check whether the group is in distribution group or not?
I have not been given more information.
Any attribute or something I can check?
This code will retrieve all your email enabled groups, regardless of whether it is a security or distribution group. (Having seen your comment to marc_s's answer, I'm guessing this is actually what your managers are looking for).
Since you're on .NET 3.5 and up, you should check out the
System.DirectoryServices.AccountManagement
(S.DS.AM) namespace. Read all about it here:Basically, you can define a domain context and easily find users and/or groups in AD:
The new S.DS.AM makes it really easy to play around with users and groups in AD!
You can retreive this information from an attribute called Groupe-Type(last line).
You can find in this answer or at the botton of this other one different ways to retreive groups a user belongs to.
You can find here how to retreive user.