MOSS提公升許可權方法

2021-09-05 22:39:00 字數 1509 閱讀 6330

1、sharepoint乙個有用的方法spsecurity.runwithelevatedprivileges(delegate(){})

今天開發的過程中用到在moss**上去訪問域控上的使用者資訊,這個我是利用ldap協議來實現的其中用的了乙個directoryentry這個類(這個類是引自system.directoryseverices這個程式集的。)例項化乙個directoryentry的物件後呼叫其中的主法來實現的,(參考:

例項化事例**段:

directoryentry bjde = new directoryentry (「");

// 當然directoryentry 還有其它的建構函式,我這裡只呼叫了乙個引數的建構函式

ok,例項化之後就可以呼叫其相應方法了,這個參考上面提供的**。當我把程式入到moss**上的時,會報意外錯誤,但在我本地開發的機器上沒有任何問題包括在虛機上。

經過一陣的的尋覓和請教發現原來是,放到moss上之後,當前登陸使用者的許可權不足進行這個域控的操作。

解決辦法:

把這與的這段**包在

spsecurity.runwithelevatedprivileges(delegate(){})   中即可。

如:spsecurity.runwithelevatedprivileges(delegate()

jcv

// 該**段在 sharepoint/system 帳戶下執行。

});  

另外還一點值得注意:spsecurity.runwithelevatedprivileges可以提公升**的執行許可權,實現模擬管理員身份的功能。

在runwithelevatedprivileges中不要使用spcontext.current.web,spcontext.current.site,spcontrol.getcontextweb(httpcontext.current)之類的根據當前上下文得到當前的web或者site,根據這些方法得到的所有物件(包括從根據這些物件得到的list,listitem等等物件)都是以當前**登入使用者許可權運作的,即使是在runwithelevatedprivileges其運作許可權也不會是管理員。

所以,如果要真正讓在runwithelevatedprivileges中的**以管理員許可權正常運作的話,必須重新初始化相應的物件,比如:

spsecurity.runwithelevatedprivileges(delegate()itpub個人空間@y8k4y~$y$a f5m

itpub個人空間kdb2uy&q

});以上mysite.rootweb.currentuser.loginname返回的是管理員的登入帳號。但是如果按之前所說使用spcontext:spsecurity.runwithelevatedprivileges(delegate()

lig oa0);這時候即使在提公升許可權的範圍內執行,得到的也是當前**登入帳戶名,而不是管理員登入帳號

kalilinux 許可權提公升

meterpeter 可以在 meterpreter 使用 incognito 來開始模擬過程 use incognito 展示 incognito 的幫助文件,通過輸入 help 命令 help 獲得可用使用者的列表 list tokens u 模擬攻擊 impersonate token wil...

Serv U FTP Server本地提公升許可權缺陷

serv u ftp server為rhinosoft出品的一款ftp server軟體,可執行在microsoft windows平台下。servuadmin.exe是ftp server管理介面,由於servuadmin.exe對異常的不正確處理,導致在serv u被 註冊為系統服務的情況下,本...

Linux許可權提公升 Kernel exploit

宣告 本文介紹的內容僅用於學習和研究目的,請勿用做非法用途。利用dirtycow漏洞提權 linux kernel 2.6.22 3.9 檢視當前使用者和核心版本資訊 whoami uname a gcc pthread dirty.c o dirty lcrypt切換到firefart使用者,可以...