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

  • Home
  • SEARCH
  • 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 191281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:19:41+00:00 2026-05-11T16:19:41+00:00

Alright, so I already have an existing connection to Active Directory on my server.

  • 0

Alright, so I already have an existing connection to Active Directory on my server. I know that querying active directory works. What I want to be able to do is query for all of the ou’s and/or groups in active directory, and also be able to find the users the belong to those groups/ous.

this is the current query that just pulls user information (or part of a stored procedure set up to pull all users):

SELECT
    userAccountControl,
    DisplayName AS [NAME],
    givenName AS FIRSTNAME,
    middleName, 
    sn AS LASTNAME,
    employeeID AS EMPID,
    telephoneNumber AS EXT,
    Title, 
    Department AS DEPT,
    Division,
    sAMAccountName AS UserName,
    mail AS Email,
    homeDirectory AS HomeDir,
    userPrincipalName AS LOGON,
    manager
FROM         OPENQUERY(ADSI, 
                      '
 select
     userAccountControl,
     DisplayName,
     givenName,
     middleName,
     sn,
     employeeID,
     telephoneNumber,
     Title,
     Department,
     Division,
     sAMAccountName,
     mail,
     homeDirectory,
     userPrincipalName,
     manager
 from ''LDAP://name''
 where sn > ''a''
    and sn <''h''
 order by DisplayName
 ')
AS derivedtbl_1
  • 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-05-11T16:19:41+00:00Added an answer on May 11, 2026 at 4:19 pm

    Are you aware of the fact that you cannot query more objects than the AD server is willing to return in one reply?

    The ADSI SQL provider does not support paging through the results. The AD server is usually configured to return the first 1000 results only.

    If you query for virtually all AD objects at once you are very likely to hit that limit.

    Can you clarify what you are trying to achieve?

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

Sidebar

Related Questions

Alright, so all modals already have an image at the top right to close
Alright, I know questions like this have probably been asked dozens of times, but
We have an existing java-based heavyweight project that needed an interactive script interpreter. After
Alright so, I have something that looks like this : for (j = 0;
I am using facebook SSO in my iOS app and that works alright. Now
Alright say that I have on a page, say form.php. On this form say
Alright so i need to open a .txt file that will be created in
Alright so I have no idea how to even begin doing this But basically
Alright so I have been looking around (on SO and Google) to see if
Alright, I have some weird behavior and this question goes to the people out

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.