You must Sign In to post a response.
  • Category: Windows

    DirectorySearcher - Clauses and keywords for search

    Hi All,

    I am very new to working Active directory. After spending some time on web i was able to get code for getting users from active directory using DirectorySearcher class. However i am facing hard time in getting a list of all supported clauses and keywords of search.

    The only link i was able to get is But got only few keywords.

    Kindly share links / list of keywords and clauses. Below are some i found;

    Also i tried creating a org chart using Visio and then with DirectorySearcher code. The visio files excludes virtual accounts such as feedback@abc,.com, meeting rooms, etc. but my Directory searcher code get them as welFrown . Kindly help.
  • #767550
    I have worked on Active directory few years back and try to fetch lot of parameters from user menu, you can check below code

    DirectoryEntry entry = new DirectoryEntry("LDAP://");
    DirectorySearcher Dsearch = new DirectorySearcher(entry);

    foreach (SearchResult sResultSet in Dsearch.FindAll())

    // Login Name
    Console.WriteLine(GetProperty(sResultSet, "cn"));
    // First Name
    Console.WriteLine(GetProperty(sResultSet, "givenName"));
    // Middle Initials
    Console.Write(GetProperty(sResultSet, "initials"));
    // Last Name
    Console.Write(GetProperty(sResultSet, "sn"));
    // Address
    string tempAddress = GetProperty(sResultSet, "homePostalAddress");

    if (tempAddress != string.Empty)
    string[] addressArray = tempAddress.Split(';');
    string taddr1, taddr2;
    taddr1 = addressArray[0];
    taddr2 = addressArray[1];
    // title
    Console.Write(GetProperty(sResultSet, "title"));
    // company
    Console.Write(GetProperty(sResultSet, "company"));
    Console.Write(GetProperty(sResultSet, "st"));
    Console.Write(GetProperty(sResultSet, "l"));
    Console.Write(GetProperty(sResultSet, "co"));
    //postal code
    Console.Write(GetProperty(sResultSet, "postalCode"));
    // telephonenumber
    Console.Write(GetProperty(sResultSet, "telephoneNumber"));
    Console.Write(GetProperty(sResultSet, "otherTelephone"));
    Console.Write(GetProperty(sResultSet, "facsimileTelephoneNumber"));

    // email address
    Console.Write(GetProperty(sResultSet, "mail"));
    // Challenge Question
    Console.Write(GetProperty(sResultSet, "extensionAttribute1"));
    // Challenge Response
    Console.Write(GetProperty(sResultSet, "extensionAttribute2"));
    //Member Company
    Console.Write(GetProperty(sResultSet, "extensionAttribute3"));
    // Company Relation ship Exits
    Console.Write(GetProperty(sResultSet, "extensionAttribute4"));
    Console.Write(GetProperty(sResultSet, "extensionAttribute5"));
    // Assigned Sales Person
    Console.Write(GetProperty(sResultSet, "extensionAttribute6"));
    // Accept T and C
    Console.Write(GetProperty(sResultSet, "extensionAttribute7"));
    // jobs
    Console.Write(GetProperty(sResultSet, "extensionAttribute8"));
    string tEamil = GetProperty(sResultSet, "extensionAttribute9");

    // email over night
    if (tEamil != string.Empty)
    string em1, em2, em3;
    string[] emailArray = tEamil.Split(';');
    em1 = emailArray[0];
    em2 = emailArray[1];
    em3 = emailArray[2];
    Console.Write(em1 + em2 + em3);

    // email daily emerging market
    Console.Write(GetProperty(sResultSet, "extensionAttribute10"));
    // email daily corporate market
    Console.Write(GetProperty(sResultSet, "extensionAttribute11"));
    // AssetMgt Range
    Console.Write(GetProperty(sResultSet, "extensionAttribute12"));
    // date of account created
    Console.Write(GetProperty(sResultSet, "whenCreated"));
    // date of account changed
    Console.Write(GetProperty(sResultSet, "whenChanged"));

    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #767559
    Thank you Prasad!

  • Sign In to post your comments