我必须使用我的 AD 域中的所有人填充基于出色 ASPTokenInput 的类似自动完成 PeopleEditor 的控件。反映 PeopleEditor 在他们的 Active Directory 搜索引擎中显示出真正的混乱,所有可能有用的类都是内部的。
我的测试方法工作正常,但我需要从 AD(不是共享点站点的)获取所有用户来填充我的列表:
public string GetUsers(string filter)
{
var spWeb = SPContext.Current.Web;
SPUserCollection allusers = spWeb.AllUsers;
List<SPUser> users = allusers.Cast<SPUser>().ToList();
var query = from spUser in users.Select(usr => new {id = usr.ID, name = usr.Name})
.Where(p => p.name.IndexOf(filter, StringComparison.InvariantCultureIgnoreCase) >= 0)
select new {id = spUser.id.ToString(), spUser.name};
return new JavaScriptSerializer().Serialize(query);
}
我怎样才能像这样查询活动目录?是否可以从 sharepoint 本身检索所有 AD 连接设置?我只需要 id 和用户名来填写我的下拉列表将其转换为 SPUserCollection 是另一件大事。
使用一些像这样的内置 SP 方法会很棒:
[SubsetCallableExcludeMember(SubsetCallableExcludeMemberType.UnsupportedSPType)]
public static IList<SPPrincipalInfo> SearchWindowsPrincipals(SPWebApplication webApp, string input, SPPrincipalType scopes, int maxCount, out bool reachMaxCount)