Sha*_*wal 5 impersonation sharepoint-api sharepoint-2010 sharepoint-object-model
我们正在使用SharePoint Foundation 2010.我们正在使用服务器对象模型创建内容数据库和网站集.我们在SharePoint中拥有超过1000个用户.由于内容数据库和网站集创建是管理任务,因此只有farm administartor可以执行此操作.在我们的例子中,任何用户都应该能够使用farm administartor帐户创建内容数据库和网站集.我们可以使用SPUser还是有其他方法可以做到这一点吗?能否请您提供我可以解决上述问题的任何代码或链接?
听起来您可能需要使用SPSecurity.RunWithElevatedPrivleges。这将允许您像应用程序池身份帐户的场管理员一样运行代码。请小心,因为它为运行代码的用户提供了完全更高的访问权限,但听起来这就是您想要的。
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite topSite = new SPSite("URL_OF_YOUR_SITE_COLLECTION"))
{
//Any code you run here would run with the permissions of the application pool identity
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
833 次 |
| 最近记录: |