M
Maziar Aflatoun
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.
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.