在 SharePoint 中自动创建网站集

发布于 2024-08-08 21:09:20 字数 1230 浏览 6 评论 0原文

更新

我现在可以成功执行 UI 模拟。这是我使用的代码的问题,在查看 Jay Nathan 的文章后,我有恢复到他的代码,一切正常。

作为对评论的回应,这是我用来创建新网站集的代码:

Dim newSite As SPSite = webApp.Sites.Add( _
    txtWebApp.Text & "/cg/" & strURL, txtName.Text, txtDesc.Text, 1033, "SITEDEF#0", _
    "DOMAIN\ACCOUNT", "NAME", "EMAIL", _
    "DOMAIN\ACCOUNT", "NAME", "EMAIL")

是的,“SITEDEF#0”是一个完全有效的网站定义。

希望我通过使用应用程序页面解决了这个问题,该页面可作为“站点操作”菜单上的一个元素(仅限站点管理员)。使用模拟我可以成功地发起这个过程。我在另一个问题中强调了一些其他问题。

< strong>原始问题

我需要允许非场管理员能够使用非常具体的网站定义创建网站集。这些人将无权访问中央管理,因此需要自定义解决方案来允许创建这些内容。我尝试了几种解决方案,但希望就推荐的方法达成共识。

  1. 自定义 Web 服务 - 我编写了一个自定义 Web 服务来执行此任务,但这引起了很大的麻烦,即使该 Web 服务使用与共享点应用程序池相同的身份在应用程序池中运行,我也无法将其发送到工作。在尝试通过 Web 服务执行此操作时也遇到了表单摘要问题。

  2. Web 部件/应用程序页面 - 这里没有表单摘要问题,因为我们位于 SharePoint 上下文中,但是我已尝试使用 RunWithElevatedPrivileges,但在调用 SPWebbApplication.Sites.Add() 时仍然被拒绝访问,即使所有 SPSite 和SPWeb pbjects 正在提升的代码块内实例化。我已尝试在 UI 级别进行直接模拟,但收到 UnhandledException,表示模拟已失败。

  3. 围绕 stsadm 的应用程序包装 - 我还没有尝试过这个,因为我担心这种方法的可行性,肯定有比这更干净的方法吗?

关于这方面的一些指导会很有用,因为我在这方面找不到太多信息。

谢谢

UPDATE

I can now perform succesful UI impersonation. This was an issue with the code I was using and after viewing Jay Nathan's article I have reverted to his code and all is working great.

In response to a comment this is the code I am using to create a new site collection:

Dim newSite As SPSite = webApp.Sites.Add( _
    txtWebApp.Text & "/cg/" & strURL, txtName.Text, txtDesc.Text, 1033, "SITEDEF#0", _
    "DOMAIN\ACCOUNT", "NAME", "EMAIL", _
    "DOMAIN\ACCOUNT", "NAME", "EMAIL")

and yes "SITEDEF#0" is a perfectly valid site defintion.

Hopefully I have overcome this issue by using an Application Page which is available as an element on the Site Actions menu (to site admins only). Using impersonation I can succesfully instigate this process. There are some additional issues which I have highlighted in another question.

ORIGINAL QUESTION

I have a need to allow non farm administrators to be able to create site collections using a very specific site definition. These people will not have access to central admin and so require a custom solution to allow the creation of these. I have tried several solutions, but want some consensus on a recommended approach.

  1. Custom Web Service - I have written a custom web service to perform this task however this caused major headaches and even though the web service was running in an app pool using the same identity as the sharepoint app pool I could not get this to work. Also had form digest issues in trying to perform this v ia a web service.

  2. Web Part/Application Page - No form digest issues here as we are in the SharePoint context, however I have tried using RunWithElevatedPrivileges but I still get an access denied when calling SPWebbApplication.Sites.Add(), even though all SPSite and SPWeb pbjects are being instantiated inside the elevated code block. I have tried direct impersonation at the UI level and I get an UnhandledException saying that impersonation has failed.

  3. Application Wrapper Around stsadm - I have not attempted this yet as I am concerned about the viability of this approach, surely there is a cleaner way than this?

Some guidance on this would be useful as I cannot find much out there on this.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

奢欲 2024-08-15 21:09:20

我会选择选项 1。这可能是授权问题。您如何访问 SharePoint?使用 SDK 还是通过其 Web 服务?

I'd go with option number 1. It's probably an authorization issue. How are you accessing SharePoint? with the SDK or trough its web services?

邮友 2024-08-15 21:09:20

我会选择第二个。该代码应该可以工作,也许模拟代码不正确?例如,您不能像平常那样使用 SPContext。

此外,您还将提升到 SharePoint 站点的应用程序池的身份。此帐户是否有足够的权限来创建网站集?
您可以在管理中心>>查看应用管理> Web 应用程序的策略。

I'd go for number 2. That code should work, maybe the impersonation code is not correct? You can't use SPContext like you normally would for instance.

Also, you are elevating to the identity of the application pool of your SharePoint site. Does this account have sufficient rights to create Site Collections?
You can check in Central Administration > Application Management > Policy for Web Application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文