sharepoint 加载用户组出现权限受限
private void BindFirstApply()
{
using (SPWeb web = SPControl.GetContextSite(Context).OpenWeb())
{
DataTable ownerTable = Make_Table();
foreach (SPUser user in web.SiteUsers)
{
for (int i = 0; i < user.Groups.Count; i++)
{
if (user.Groups[i].ToString() == "项目经理" && user.Name.ToString() != "System Account")
{
DataRow newRow = ownerTable.NewRow();
newRow["Name"] = user.Name.ToString();
newRow["LoginName"] = user.LoginName;
ownerTable.Rows.Add(newRow);
}
}
}
DropDownListFirstApplyer.DataSource = ownerTable;
DropDownListFirstApplyer.DataTextField = "Name";
DropDownListFirstApplyer.DataValueField = "LoginName";
DropDownListFirstApplyer.DataBind();
}
}
private DataTable Make_Table()
{
DataTable nameTable = new DataTable("Names");
nameTable.Columns.Add("Name");
nameTable.Columns.Add("LoginName");
return nameTable;
}