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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:06:58+00:00 2026-06-01T05:06:58+00:00

We use sharepoint, and in SP we have a people picker which searches on

  • 0

We use sharepoint, and in SP we have a people picker which searches on samaccountname but also on name. On dev it works fine, but on prod it returns sometimes duplicated results.

I wonder if there is an easy application there which I can make queries against the AD and see the results. (Maybe the duplicated users are really in different domains in one ad forest or something.

I found this, but it doesnt have a working example in c#
http://msdn.microsoft.com/en-us/library/ms973834.aspx

  • 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-01T05:06:59+00:00Added an answer on June 1, 2026 at 5:06 am

    I’ve got two snippets for this :

    using System.DirectoryServices.AccountManagement;
    using System.DirectoryServices;
    
    // Authentication
    using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, sDn))
    {
       // validate the credentials
       bIsValid = pc.ValidateCredentials(sUsr, sPassword);
    }
    
    //List users
    DirectorySearcher adsSearcher = new DirectorySearcher();
    adsSearcher.Filter = string.Format(Parameters.ActiveDirectoryFilter, "*");
    try
    {
       foreach (SearchResult sr in adsSearcher.FindAll())
       {
           string sUsrName = sr.GetDirectoryEntry().Properties["UserPrincipalName"].Value as string;
           Console.WriteLine(string.Format("User : {0}", sUsrName));
       }
    }
    

    Of course, it needs two references (System.DirectoryServices and System.DirectoryServices.AccountManagement).

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

Sidebar

Related Questions

I have the following code, its a custom people picker for sharepoint 2010. It
So you don't have programming privileges on a SharePoint Server but you can use
I have created sharepoint application for internal use. But it is not accessed in
Have you tried to use SharePoint with version control such as Perforce (or Subversion),
We have online SharePoint site and we want to use tool or any way
I have a page layout that I use in my SharePoint solution when I
I am planning to use my laptop for SharePoint 2010 development and I have
i have an LMS coded with Sharepoint & c#. i want to use scorm,
I would like to use Sharepoint Designer 2007 as an html editor. I have
I have a custom search webpart in Sharepoint which have 7 filters. I am

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.