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 3306326
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:16:32+00:00 2026-05-17T21:16:32+00:00

I managed to do ASP.NET authentication work wih AD. Now, I want to query

  • 0

I managed to do ASP.NET authentication work wih AD. Now, I want to query an OU in AD and display the result
either ListView or GridView in ASP.NET page.

Here’s the Domain Controller: dc.itlab.edu

The OU: UsersStudents

In the organizational unit (OU) UsersStudents there are following columns:

First Name, Last Name, Pre-Windows 2000 Logon Name, Name , Type

I want to query column First Name, Last Name, Pre-Windows 2000 Logon Name in OU UsersStudents and bind the
result to ListView or GridView.

Thank you for suggestion either in C# or VB.NET.

  • 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-17T21:16:32+00:00Added an answer on May 17, 2026 at 9:16 pm

    If you are on .NET 3.5, or could upgrade to it – the LDAP stuff has been vastly improved with the introduction of the System.DirectoryServices.AccountManagement namespace.

    It contains among other things classes like UserPrincipal, which offers most of the commonly used LDAP attributes as properties. Using the PrincipalSearcher and QBE (Query-by-example), you could very easily find those users (or other objects) you’re interested in and binding them to the ASP.NET grid view.

    To learn more about the new .NET 3.5 stuff, read this excellent article at MSDN Magazine:

    Managing Directory Security Principals in the .NET Framework 3.5 – January 2008 issue

    Update: Using the .NET 3.5 interface, you can write code something like this:

    // define the content - domain name (second param) must be NetBIOS-style,
    // third parameter is the container where to create the context for
    PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "ITLAB", "OU=UsersStudents,DC=dc,DC=itlab,DC=edu");
    
    // define your "prototype" for the searcher - here: you want to search for 
    // users which have the .Enabled property set to true; you could define additional
    // requirements here
    UserPrincipal qbePrototype = new UserPrincipal(ctx);
    qbePrototype.Enabled = true;
    
    // create PrincipalSearcher based on that QBE prototype
    PrincipalSearcher ps = new PrincipalSearcher(qbePrototype);
    
    // find all matching Principals - in your case, those will be of type UserPrincipal
    PrincipalSearchResult<Principal> results = ps.FindAll();
    

    Now you should be able to bind the results directly to a DataGridView or something, and pick out those properties for your columns that you’re looking for:

    • First Name = UserPrincipal.GivenName
    • Last Name = UserPrincipal.Surname
    • Pre-Windows 2000 Logon Name = UserPrincipal.SamAccountName
    • Name = Name
    • Type = ?? What you do mean here??
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ASP.NET - I've managed to siginificantly reduce the number of .axd requests a page
Can there be buffer overflow/overrun vulnerabilities in completely managed asp.net web portal.If yes how
I have an ASP.NET page which has a script manager on it. <form id=form1
I am trying to create a custom authentication scheme in ASP.NET MVC using form
I have a couple of solutions, but none of them work perfectly. Platform ASP.NET
I'm currently using Subversion to manage my ASP.NET website. I'm finding that whenever I
We have an ASP.NET application that manages it's own User, Roles and Permission database
My Manager asked me to code in ASP.net. What is meant my imperative and
I am using asp.net web site administration tool to manage the different roles in
I manage a web application for a client with the following specs: ASP.net 3.5

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.