错误截图错误日志位置:C:\ProgramFiles\CommonFiles\microsoftshared\WebServerExtensions\15\LOGS主要错误ThecurrentuserisnotanSharePointServerfarmadministrator.处理过程查看了当前User确实不是场管理员,但......
2022-04-11 67 SharePoint ERROR the current user not Server farm 错误
两个自己平时写的方法,记录下来,方便以后查找使用;
1、判断用户是否在字段人员和组里面;
复制代码
public static bool IsUserInFiled(int UserID, string ListName, int ItemID, string FieldInterName)
{
bool value = false;
try
{
using (SPSite site = new SPSite(SITERUL))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists.TryGetList(ListName);
SPListItem item = list.GetItemById(ItemID);
string dispName = list.Fields.GetFieldByInternalName(FieldInterName).Title;
SPFieldUserValueCollection uu = new SPFieldUserValueCollection(web, item[dispName].ToString());
foreach (SPFieldUserValue u in uu)
{
if (u.User != null)
{
if (UserID == u.User.ID)
value = true;
}
else
{
string userStr = u.ToString().Split(';')[0];
int groupID = Convert.ToInt32(userStr);
SPGroup group = web.SiteGroups.GetByID(groupID);
foreach (SPUser user in group.Users)
{
if (UserID == user.ID)
value = true;
}
}
}
}
}
}
catch { }
return value;
}
复制代码
2、获取Menu菜单,有点弱爆的赶脚;
复制代码
public static string GetMenu(string ListName)
{
string menuHtml = string.Empty;
using (SPSite site = new SPSite(SITEURL))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists.TryGetList(ListName);
SPQuery query = new SPQuery();
query.Query = "";
SPListItemCollection itemcoll = list.GetItems(query);
foreach (SPListItem item in itemcoll)
{
string Title = list.Fields.GetFieldByInternalName("Title").Title;
string Link = list.Fields.GetFieldByInternalName("Link").Title;
string IsShow = list.Fields.GetFieldByInternalName("IsShow").Title;
string IsOpenNewPage = list.Fields.GetFieldByInternalName("IsShow").Title;
menuHtml += item[Title].ToString();
}
}
}
return menuHtml;
}
复制代码
备 注
仅作个人记录,如有需要,记得先调试哦;
相关文章
SharePoint2013爬网报错AnunrecognizedHTTPresponsewasreceivedwhenattemptingtocrawlthisitem.Verifywhethertheitemcanbeaccessedusingyourbrowser.然后登陆网站,发现在服务器上输入3次用户名密码白页,考虑到......
2022-04-11 449 SharePoint ERROR unrecognized HTTP response was received
最近使用SharePoint中,遇到一个需要重命名网站集的需求,主要是网站用数据库备份/还原的方式,想要改网站集的地址,然后搜了一下PowerShell:$site=Get-SPSite-Identityhttp://server/sites/Demo$site.......
2022-04-11 299 SharePoint重命名网站集名称