"Ziemowit" <zi*******@wp.p l> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com...
No problem, examples directly from my code with short comments:
public string GetDisplayName( string cn) //cn is unique for user
{
string FullName = "";
try
{
DirectoryEntry entry = new
DirectoryEntry( "LDAP://server/DC=yourdomain,D C=com"); //path for
server that store AD, can be domain server
entry.Authentic ationType = AuthenticationT ypes.ReadonlySe rver; //we
want only readonly access
entry.Username = "username"; //if domain allow anonymous access
to AD application then these two rows are not required
entry.Password = "password"; //if not, then you will need domain
account to acces to AD server
DirectorySearch er search = new DirectorySearch er(entry);
search.Filter = "(cn="+cn+" )";
search.Properti esToLoad.Add("d isplayName"); //name of property to
load
SearchResult sr = search.FindOne( );
if (sr != null)
{
FullName = sr.Properties["displayNam e"][0].ToString(); //read
property
}
search.Dispose( );
entry.Dispose() ;
}
catch
{
}
return FullName; //thats all
}
You have to check if your application have access to AD server and
create domain account if required. To get info what LDAP paths should
be I suggest you to use LDAPBrowser - cool software for browsing LDAP.
I hope it helps
Ziemowit
I'm a vb user and c# is a bit greek to me but I think I can adapt and
overcome. :)
Yesterday I went through the System.Director yServices.Activ eDirectory
namespace in hopes of finding something useful in there for my purposes and
after getting lost of a while, was unable to find anything to suit my
purpose. Oh well.
Thanks for the help. I'll put it to good use.
Jim