Hi All !!!!!!!
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;