Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8477209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:23:54+00:00 2026-06-10T18:23:54+00:00

How can I fetch all the record from my Active Directory Server in asp.net

  • 0

How can I fetch all the record from my Active Directory Server in asp.net c#?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:23:55+00:00Added an answer on June 10, 2026 at 6:23 pm

    Make a connection string in LDAP providing username and Password which can communicate with the server and have Administrator rights.

    Suppose DC is me.com and username and password are the password of that user Id which is having Administrator rights.

       DirectoryEntry rootDSE = rootDSE = new DirectoryEntry("LDAP://OU="",OU=" ",dc="me",dc=com", username, password);
    
        DirectorySearcher search = new DirectorySearcher(rootDSE);
    
        search.PageSize = 1001;// To Pull up more than 100 records.
    
         search.Filter = "(&(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2))";//UserAccountControl will only Include Non-Disabled Users.
          SearchResultCollection result = search.FindAll();
    
             foreach (SearchResult item in result)
            {
                if (item.Properties["cn"].Count > 0)
                {
                    DisplayName = item.Properties["cn"][0].ToString();
                }
                if (item.Properties["mail"].Count > 0)
                {
                    EmailAddress = item.Properties["mail"][0].ToString();
                }
                if (item.Properties["SamAccountName"].Count > 0)
                {
                    DomainName = item.Properties["SamAccountName"][0].ToString();
                }
                if (item.Properties["department"].Count > 0)
                {
                    Department = item.Properties["department"][0].ToString();
                }
                if (item.Properties["title"].Count > 0)
                {
                    title = item.Properties["title"][0].ToString();
                }
                if (item.Properties["company"].Count > 0)
                {
                    company = item.Properties["company"][0].ToString();
                }
                if (item.Properties["DistinguishedName"].Count > 0)
                {
                    memberof = item.Properties["DistinguishedName"][0].ToString();
                }
                if (item.Properties["AccountExpirationDate"].Count > 0)
                {
                    string aaa = item.Properties["AccountExpirationDate"][0].ToString();
                }
    
                  dt.Rows.Add(DisplayName, EmailAddress, DomainName, Department, title, company, memberof);
                 DisplayName = string.Empty;
                 EmailAddress = string.Empty;
                 DomainName = string.Empty;
                 Department = string.Empty;
                 title = string.Empty;
                 company = string.Empty;
                 memberof = string.Empty;
    
                   rootDSE.Dispose();
    

    In this way we can Pull up all the records from our Domain Server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I fetch more than 1000 record from data store and put all
In Entity framework 4.0 how can we fetch multiple record set from database in
I can fetch the menucode from database i can print inside for loop means
I can fetch the item names from a database and append them to an
Is there any way we can fetch X509 Public Cetrificates using c# from AD
I am fetching email from gmail where I can fetch body, name of the
I want fetch last record using hibernate criteria Can u help me?
I want to pull data from table Province_Notifiers and also fetch all corresponding items
I have select query that fetch record based on a condition Select * from
I would like to fetch all records from particular day, no matter what time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.