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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:38:02+00:00 2026-05-16T01:38:02+00:00

I want to get user names in active directory by using sharepoint webpart. any

  • 0

I want to get user names in active directory by using sharepoint webpart.
any way a i can get usernames by using ASP. net but i cant convert that code in to sharepoint web part….

here is the code ………

          using System;
          using System.Collections.Generic;
          using System.Linq;
          using System.Web;
          using System.Web.UI;
          using System.Web.UI.WebControls;
          using System.DirectoryServices;
          using System.Data;


        string domain = "LDAP://serverName";
        DirectoryEntry entry = new DirectoryEntry(domain);

        DirectorySearcher searcher = new DirectorySearcher(entry);

        searcher.Filter = "(&(objectClass=user))";

        SearchResultCollection resultCol = searcher.FindAll();

        //Link list for store user names 
        List<String> User_Names = new List<String>();

        int count = 0;

        foreach (SearchResult result in resultCol)
        {
            User_Names.Add(result.Properties["CN"][0].ToString());
            count = count + 1;
        }

        //can print all user names by using for loop or while loop 

        Label2.Text = RadioButtonList1.SelectedItem.Text;
  • 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-16T01:38:02+00:00Added an answer on May 16, 2026 at 1:38 am

    Here’s a little something to get you started. It’s a skeleton for a .NET web part class that includes a data-bound RadioButtonList. To get it deployed to SharePoint, you will also need to roll together a proper .webpart manifest. There are lots of examples of these on the web, and Visual Studio 2010 projects for SharePoint 2010 make it super easy with the Visual Web Part template. (Note that if you are using the Visual Web Part template, then you can write up the web part with an .ascx file like you would any other user control, instead of using CreateChildControls() as I do below.)

    Good luck!

    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    
    /// <summary>
    /// This web part provides redirection logic to a page.
    /// </summary>
    public class RedirectWebPart : System.Web.UI.WebControls.WebParts.WebPart
    {
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            RadioButtonList list = new RadioButtonList();
            Controls.Add(list);
    
            list.AutoPostBack = true;
            list.SelectedIndexChanged += new EventHandler(this.OnSelectedNameChanged);
    
            // On the next line, ADUtility.GetActiveDirectoryNames() is a dummy
            // class and method that you should replace with your AD query logic.
            // It just needs to return an enumerable collection of strings.
            list.DataSource = ADUtility.GetActiveDirectoryNames();
            list.DataBind();
        }
    
        protected void OnSelectedNameChanged(object sender, EventArgs e)
        {
            // Your event-handling logic.
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Flex 4 / Air 2.0.3 Is it possible to get the active directory
I'm using the following query to get the id and the username of a
I have a page where I am using a PHP while loop to echo
I have a Rails 3 application with a User class, and a tab-delimited file
I have a LoginControl that works great, however, I want it to store more
I've got this complex filtering mechanism... d = copy(request.GET) d.setdefault('sort_by', 'created') d.setdefault('sort_dir', 'desc') form
I have an apache webserver that is used to serve php and static web
I have created a sign-up and login for my website and all validation works
When I execute the following cucumber script: Feature: Manage Customers In order to store
I'm not sure if I phrased that correctly but here's my dilemma. I inherited

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.