Question : How do I find user group information from LDAP using c#

I'm really new to LDAP and I have to learn how to get the user group information using c#.  My inputs are:

IP address of the LDAP server
domain name
userID

And then I have to return the group user info.

Yikes.  Help me please.   I only had 80 points left to ask this question.  I am sorry.

Answer : How do I find user group information from LDAP using c#


Hey :)

Something like this?

Chris
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
using System.DirectoryServices;
 
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            String ipAddress = "1.3.4.5";
            String ldapFilter = "(sAMAccountName=TheUsername)";
 
            DirectoryEntry adDomain = new DirectoryEntry("LDAP://" + ipAddress);
            DirectorySearcher adSearch = new DirectorySearcher(adDomain, ldapFilter);
            adSearch.PropertiesToLoad.AddRange(new String[] {"name", "memberOf"} );
 
            SearchResult adResult = adSearch.FindOne();
 
            Console.WriteLine(adResult.Properties["name"][0].ToString() + " is a member of:");
            foreach (Object adGroup in adResult.Properties["memberof"])
            {
                Console.WriteLine(adGroup.ToString());
            }
        }
    }
}
Random Solutions  
 
programming4us programming4us