访问SPUser的所有组(包括Active Directory组)的最佳方法是什么?
c, err := smtp.Dial(host + ":25")
if err != nil {
log.Panic(err)
}
if err = c.Hello(host); err != nil {
log.Panic(err)
}
if err = c.StartTLS(config.TLS()); err != nil {
log.Panic(err)
}
有没有办法访问用户所在的所有群组,包括AD群组?
答案 0 :(得分:1)
如果您需要当前网站集中的所有用户,可以从隐藏列表中访问它 UserInformationList
The User Information List can be accessed (Only if you’re admin) via the browser by navigating to /_catalogs/users/simple.aspx
在这里阅读更多内容: https://zimmergren.net/sharepoints-hidden-user-list-user-information-list/
来自AD:
DirectoryEntry myLdapConnection = new DirectoryEntry("LDAP://YouDomainName");
DirectorySearcher search = new DirectorySearcher(myLdapConnection) { Filter = ("(objectClass=user)") };
search.CacheResults = true;
SearchResultCollection allResults = search.FindAll();
DataTable resultsTable = new DataTable();
resultsTable.Columns.Add("UserID");
resultsTable.Columns.Add("EmailID");
foreach (SearchResult searchResult in allResults)
{
MembershipUser myUser = Membership.GetAllUsers()[searchResult.Properties["sAMAccountName"][0].ToString()];
if (myUser == null)
{
DataRow dr = resultsTable.NewRow();
dr["UserID"] = searchResult.Properties["sAMAccountName"][0].ToString();
if (searchResult.Properties["mail"].Count > 0)
{
dr["EmailID"] = searchResult.Properties["mail"][0].ToString();
}
else
{
dr["EmailID"] = "";
}
resultsTable.Rows.Add(dr);
}
else
{ }
}