User-294535585 posted
I am hoping that someone can help me. I am doing a search to return all accounts in AD that have never been logged into and were created before a specified date but I keep getting the error "search filter is invalid." Here is my code.
string ADPath =
"LDAP://DC=ad,DC=Domain,DC=com";
DirectoryEntry AD =
new DirectoryEntry(ADPath,
"Username", "Pwd");
DirectorySearcher ADFind =
new DirectorySearcher(AD);
ADFind.Filter = ADFind.Filter =
"(&(objectCategory=user)(!lastLogonTimestamp=*) (whenCreated>=20070301000000.0Z)))";
SearchResultCollection results = ADFind.FindAll();