Re: browsing AD with asp.net

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I instantiated DirectoryEntry this way:

DirectoryEntry de=new
DirectoryEntry(LDAP://<my.organization.extension>/DC=<my>,DC=<organization>,DC=<extension>,

<domain\userid>, <domain password>);

Pls. note that <domain\userid> is my domain user, which works in the
console application.

After that:

irectorySearcher searcher = new DirectorySearcher(de);
string sFilter = "(&(objectCategory=person)(objectClass=user))";
searcher.Filter = sFilter;
searcher.SearchScope = System.DirectoryServices.SearchScope.Subtree;
SearchResultCollection results = searcher.FindAll();

which works great and I retrieve a list of users.
But now for each user I want other details, therefore I do this, for
example to get LastLogin, because it is easier than using
SirectoryEntry:

string lastlog;
ActiveDs.IADsUser IADsDe = (ActiveDs.IADsUser) UE.NativeObject;
lastlog=IADsDe.LastLogin.ToString("yyyy-MM-dd hh:mm");


Which gives the COMException.

I have seen I can get the properties and their values via the
DirectoryEntry, but it is a bit of a hassle, since they are a bit
messy.
But I will do it that way.

Thanks for your time and help!

.