LDAP query Filter error RRS feed

  • Question

  • 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();


    Tuesday, April 10, 2007 1:41 PM

All replies

  • User-294535585 posted

    I don't know why my copy paste did this but it isn't


    ADFind.Filter = ADFind.Filter =

    "(&(objectCategory=user)(!lastLogonTimestamp=*) (whenCreated>=20070301000000.0Z)))";

    it really is


    ADFind.Filter = "(&(objectCategory=user)(!lastLogonTimestamp=*) (whenCreated>=20070301000000.0Z)))";

    Tuesday, April 10, 2007 2:20 PM