Hi
Does anyone have any sample code on Pulling user data from Active
Directory??

Thanks

Re: Pulling user data from Active Directory by Kevin

Kevin
Fri Apr 14 05:22:26 CDT 2006

This is done using the System.DirectoryServices namespace. You can get
information about the namespace here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdirectoryservices.asp

Specifically, you would use the LDAP protocol with a
System.DirectoryServices.DirectoryEntry instance. You can read up on this
class at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdirectoryservicesdirectoryentryclassctortopic.asp

The documentation for the constructor has some nice samples:

http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdirectoryservicesdirectoryentryclassctortopic.asp?frame=true

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

If the truth hurts, wear it.


"Joe Spears" <joespears@hotmail.co.uk> wrote in message
news:WHI%f.52205$8Q3.14978@fe1.news.blueyonder.co.uk...
> Hi
> Does anyone have any sample code on Pulling user data from Active
> Directory??
>
> Thanks
>



Re: Pulling user data from Active Directory by Raghu

Raghu
Mon Apr 17 13:36:17 CDT 2006

Here is a sample:

using System.DirectoryServices;
using System.Security.Principal;


public void LearnLDAPUserQuery()
{
string userPath = "CN=my user,OU=Users and Computers,DC=corp";
string ldapPrefix = "LDAP://";

DirectoryEntry userEntry = new DirectoryEntry(ldapPrefix +
userPath);

Console.WriteLine(userEntry.Path);
Console.WriteLine(userEntry.SchemaClassName);
foreach (string propName in userEntry.Properties.PropertyNames)
{
Console.WriteLine("{0}: {1}", propName,
userEntry.Properties[propName].Value);

}

dumpActiveDirectorySecurity(userEntry.ObjectSecurity);
Console.WriteLine("logonCount: {0}",
userEntry.Properties["logonCount"].Value);
}

private void dumpActiveDirectorySecurity(ActiveDirectorySecurity
security)
{
NTAccount groupAccount = security.GetGroup(typeof(NTAccount)) as
NTAccount;
Console.WriteLine("User belongs to group: {0}",
groupAccount.Value);
}


"Joe Spears" <joespears@hotmail.co.uk> wrote in message
news:WHI%f.52205$8Q3.14978@fe1.news.blueyonder.co.uk...
> Hi
> Does anyone have any sample code on Pulling user data from Active
> Directory??
>
> Thanks
>