![](/img/trans.png)
[英]Can not load file or assembly on SharePoint 2013 Farm Solution
[英]How do I get the Active Directory Information with Sharepoint programatically on sharepoint 2013 Farm Solution On Code Behind File?
我想在列表中的共享點中獲取Active Directory名稱。
要知道SharePoint 2013具有一些隱藏的URL,該URL顯示了我希望將其輸入到列表中的當前Active Directory用戶。
http://{YourSharepointUrl}/_catalogs/users/simple.aspx
現在我要在共享點上顯示所有名稱的列表
我正在使用代碼:
private static void GetAllSiteUsers()
{
// Starting with ClientContext, the constructor requires a URL to the server running SharePoint.
var sharepointContext = new ClientContext("http://yoursharepointurl/");
}
現在我得到錯誤,它說關於程序集引用不存在。所以我在google上檢查並添加了此ddl,並使用Microsoft.SharePoint.Client;
添加了該錯誤Microsoft.SharePoint.Client;
也請參考。仍然無法正常工作。
請讓我知道需要做什么
制作程序的目的:擁有所有AD用戶並創建一個工作組,以便在分配grp時可以在iframe展示中打開某些其他URL時以這種方式為他們分配一些權限。 並且向他展示了iframe中其他網址以外的其他網址。
謝謝大家。
要獲取有關活動目錄用戶或組的所有信息,可以使用
PrincipalContext pContext = new PrincipalContext (ContextType.Domain, YOUR_DOMAIN);
//對於用戶
UserPrincipal userPrincipal = new UserPrincipal (pContext);
PrincipalSearcher userSearch = new PrincipalSearcher (userPrincipal);
//對於組
GroupPrincipal grpPrincipal = new GroupPrincipal (pContext);
PrincipalSearcher grpSearch = new PrincipalSearcher (grpPrincipal);
foreach (UserPrincipal result in userSearch.FindAll())
{
if (result.SamAccountName!= null)
// Your code
}
foreach (GroupPrincipal result in grpSearch.FindAll())
{
if (result != null)
{
// Your code
}
部件
System.DirectoryServices.AccountManagement
命名空間
using System.DirectoryServices.AccountManagement;
您在服務器端(農場解決方案),因此請不要使用:ClientContext,這是針對客戶端應用程序而不是服務器的。
您只需要獲取: 用戶信息列表
您可以嘗試類似的東西:
using(SPSite site = new SPSite("URLsiteCollection")){
using(SPWeb web = site.rootWeb){
SPList userList = web.SiteUserInfoList;
SPListItemCollection allUsers = userList.Items;
foreach(SPListItem userItem in allUsers){
string userEmail = Convert.Tostring(userItem["EMail"]);
string userName = userItem.Title;
....
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.