locked
Query enabled active directory users? RRS feed

  • Question

  • User1355545883 posted

    Hi guys, I'm a complete beginner with Active Directory, never having done anything with it.  So here's probably a basic question.

    Can I run a simple query from within an application to get all enabled active directory users?

    I appreciate any direction you can give me.

    Thursday, April 22, 2010 3:43 PM

All replies

  • User197322208 posted

    http://www.primaryobjects.com/CMS/Article61.aspx

    Also, for more info,

    http://www.codeproject.com/KB/system/everythingInAD.aspx

    Thursday, April 22, 2010 5:52 PM
  • User1355545883 posted

    http://www.primaryobjects.com/CMS/Article61.aspx

    Also, for more info,

    http://www.codeproject.com/KB/system/everythingInAD.aspx

     

    Thanks for the help.  Here's the function to get all users. Do you know how I might get all enabled users?

     

    Tuesday, April 27, 2010 11:37 AM
  • User1355545883 posted

    Oops.  I forgot to add the function in my previous post.  Do you know how I might modify it to query all enabled users?

    private DirectoryEntry GetAllUsers()
    {
          DirectoryEntry de = GetDirectoryObject();
          DirectorySearcher deSearch = new DirectorySearcher();
          deSearch.SearchRoot = de;
    
          deSearch.Filter = "(&(objectClass=user))";
          deSearch.SearchScope = SearchScope.Subtree;
          SearchResult results = deSearch.FindOne();
    
          if (!(results == null))
          {
             de = new DirectoryEntry(results.Path, "administrator", "password", AuthenticationTypes.Secure);
             return de;
          }
          else
          {
             return null;
          }
    }

    I truly need your help.

    Wednesday, April 28, 2010 9:40 AM