SharePoint 2010 獲取當前使用者的許可權

2021-09-06 05:43:58 字數 1201 閱讀 3558

本文介紹如果獲取當前登入使用者許可權(所有操作都是在可視web部件中進行的):

1.判斷當前使用者是否具有完全控制許可權

spweb web=spcontext.current.web; 

sproledefinitionbindingcollection usersroles = web.allrolesforcurrentuser; 

sproledefinitioncollection siterolecollection = web.roledefinitions; 

sproledefinition roledefinition = siterolecollection["完全控制"];   

if (usersroles.contains(roledefinition)) 

spweb web=spcontext.current.web;

sproledefinitionbindingcollection usersroles = web.allrolesforcurrentuser;

sproledefinitioncollection siterolecollection = web.roledefinitions;

sproledefinition roledefinition = siterolecollection["完全控制"];

if (usersroles.contains(roledefinition))

注意,如果你的sharepoint 版本是英語版本,請將完全控制四個字換成:full control

2.判斷當前使用者所在的組

spweb web=spcontext.current.web;  

spgroup group = web.groups["team site所有者"]; 

if (group.containscurrentuser) 

spweb web=spcontext.current.web;

spgroup group = web.groups["team site所有者"];

if (group.containscurrentuser)

注意:如果你的是英文版本,請將team site所有者 換成:team site owners

總結:能獲取當前使用者所在的許可權組及使用者組,也就知道當前登入使用者的許可權了。

**:

簡單配置 SharePoint 2010

一 初始場配置嚮導 sharepoint 產品配置嚮導 安裝完成之後,自動轉到 初始場配置嚮導 其鏈結位址為 http moss10 2012 admin adminconfigintro.aspx?scenarioid adminconfig welcomestringid farmconfigu...

簡單配置 SharePoint 2010

一 初始場配置嚮導 sharepoint 產品配置嚮導 安裝完成之後,自動轉到 初始場配置嚮導 其鏈結位址為 http moss10 2012 admin adminconfigintro.aspx?scenarioid adminconfig welcomestringid farmconfigu...

SharePoint 2010 許可權內容

對於 sharepoint 2010 的許可權來說,需要理解 sharepoint 使用者組的概念,使用者組對訪問 sharepoint 的使用者進行分組,以便於許可權管理。而許可權分類則類似於通常意義上的角色。需要特別注意的一點是,sharepoint 使用者組是屬於整個 集,而不是屬於某個 在 ...