我想通過使用sharepoint webpart獲取活動目錄中的用戶名。 任何方式,我可以通過使用ASP獲取用戶名。淨,但我不能轉換的代碼中的SharePoint Web部件....如何獲取用戶Sharepoint web部件中的域名?
這裏是代碼.........
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;