WSS3 Elevation of Privilege 替代 用户身份模拟Impersonate 进行权限提升
2007-06-14 00:47
811 查看
正文:
WSS3 中的 Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges 替代 Impersonate 进行权限提升.
好处就是根本不需要在配置文件写些什么用户名密码, 省了麻烦, 加了一定密码泄漏安全, 但是也增加了不安全代码的后门.
RunWithElevatedPrivileges 使用的是你IIS Application的进程池帐户,所以注意安全,嘿嘿.
SPSecurity.RunWithElevatedPrivileges(delegate()
{
// 用系统帐户做操作
});
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(SPContext.Current.Site.ID))
{//注意要new一个, 用SPContext.Current.Site的话,那就是当前帐户的安全级别
//用系统帐户操作这个site
}
});
照抄MSDN的代码例子:
SPWeb web = SPContext.Current.Web;
SPUser user = web.CurrentUser; // the calling user
原文地址:(http://msdn2.microsoft.com/en-us/library/aa543467.aspx
类别: SharePoint
发布日期: 2007-6-14 20:43
WSS3 中的 Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges 替代 Impersonate 进行权限提升.
好处就是根本不需要在配置文件写些什么用户名密码, 省了麻烦, 加了一定密码泄漏安全, 但是也增加了不安全代码的后门.
RunWithElevatedPrivileges 使用的是你IIS Application的进程池帐户,所以注意安全,嘿嘿.
SPSecurity.RunWithElevatedPrivileges(delegate()
{
// 用系统帐户做操作
});
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(SPContext.Current.Site.ID))
{//注意要new一个, 用SPContext.Current.Site的话,那就是当前帐户的安全级别
//用系统帐户操作这个site
}
});
照抄MSDN的代码例子:
SPWeb web = SPContext.Current.Web;
SPUser user = web.CurrentUser; // the calling user
// Uses the SHAREPOINT\system creds with the SPUser's identity reference of user SPSecurity.RunWithElevatedPrivileges(delegate() { // Gets a new security context using SHAREPOINT\system using (SPSite site = new SPSite(this.Page.Request.Url.ToString())) { using (SPWeb thisWeb = site.OpenWeb()) { thisWeb.AllowUnsafeUpdates = true; SPList theList = thisWeb.Lists[listName]; SPListItem record = theList.Items.Add(); record["User"] = user; // calling user record.Update(); // uses SHAREPOINT\system } } });
原文地址:(http://msdn2.microsoft.com/en-us/library/aa543467.aspx
类别: SharePoint
发布日期: 2007-6-14 20:43
相关文章推荐
- SharePoint v3:忘掉模拟用户Impersonate,SPSecurity.RunWithElevatedPrivileges来了 提升SharePoint代码的权限
- 如果应用程序正在通过 <identity impersonate="true"/> 模拟,则标识将为匿名用户(通常为 IUSR_MACHINENAME)或经过身份验证的请求用户。
- EventHandler中如何提升用户权限(模拟管理员权限)
- EventHandler中如何提升用户权限(模拟管理员权限)
- EventHandler中如何提升用户权限(模拟管理员权限)
- moss如何提升权限或者模拟用户
- MS Windows SeImpersonatePrivilege权限提升漏洞
- ASP.NET中模拟管理员用户提升权限
- Moss2007 提升代码的运行权限,实现模拟管理员身份的功能
- MOSS模拟管理员权限,权限提升
- SharePoint v3:忘掉模拟用户Impersonate,SPSecurity.RunWithElevatedPrivileges来了
- 一个在.net下进行用户模拟的类
- 对操作oracle数据库的用户进行安全权限控制
- JMeter模拟多个用户进行登录
- 在ASP.Net中模拟新的用户身份
- CentOS使用sudo临时提升用户权限
- 通过脚本命令cacls提升某个用户都某路径的操作权限
- 管理员在domino ad中无法对用户文件进行操作,提示无权限
- “System.OutOfMemoryException”类型的异常在 mscorlib.dll 中发生,但未在用户代码中进行处理
- 对用户登陆ftp、ssh、telnet的权限进行控制