Sharepoint Forms身份验证使用不同的帐户运行

发布于 2024-08-08 05:19:51 字数 173 浏览 2 评论 0原文

我是一个在网站集下创建子网站的控制台应用程序 网站集仅接受基于表单的用户。

现在,当我运行控制台应用程序时,它带有 Windows 凭据。

我需要某种方法来在控制台应用程序中运行代码,该应用程序创建子网站以在该网站集的管理员表单用户下运行。

请让我知道您的建议。

谢谢

I a console application that creates a sub sites under a site collection
The site collection accepts only forms based user.

Now, when i run the console application, its with windows credentials.

I need some way to run the code in console app that creates sub site to run under forms user who is admin to that site collection.

Please let me know your suggestions.

Thanks

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

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

发布评论

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

评论(1

那请放手 2024-08-15 05:19:51

您需要在管理中心 Web 应用程序 ([12 hive]\AMDISAPI) 中创建新的 Web 服务,并添加创建子网站的函数。

下面是一个示例 - 来自 SharePoint 的 hstCreateSubSite 函数托管项目:

/// <summary>
/// Method to create a Sub site for a site collection
/// </summary>
/// <param name="strSiteURL">url of the sitecollection i.e. "http://www.sitea.com"</param>
/// <param name="subsitePath">the path to the subsite i.e. inventory</param>
/// <param name="strTitle">sub site title</param>
/// <param name="strDesc">sub site description</param>
/// <param name="strTemplate">a valid templateID</param>
/// <param name="nLCID">the LCID for the language i.e. 1033 for english</param>
[WebMethod]
public void hstCreateSubSite(string strSiteURL, string subSitePath, string strTitle, string strDesc, string strTemplate, uint nLCID)
{

    SPSite oSite = new SPSite(strSiteURL); 
    SPWeb oSubSiteWeb = oSite.OpenWeb();

    SPWeb oWeb = null;

    if (String.IsNullOrEmpty(strDesc)) strDesc = null;
    if (String.IsNullOrEmpty(strTitle)) strTitle = null;

    try
    {
        // elevate permissions to allow user to create a new site.
        SPSecurity.RunWithElevatedPrivileges(delegate()
        {
            // the subsite will inherit permissions and will not convert the site if it exists
            oWeb = oSubSiteWeb.Webs.Add(subSitePath, strTitle, strDesc, nLCID, strTemplate, false, false);

            SPNavigationNodeCollection nodes = oSubSiteWeb.Navigation.TopNavigationBar;
            SPNavigationNode navNode = new SPNavigationNode(strTitle, subSitePath);
            nodes.AddAsLast(navNode);

            oWeb.Navigation.UseShared = true;

            // create entry in property bag to store template and url in the subsite.
            oWeb.AllowUnsafeUpdates = true;
            // add the Templateid to the property bag. This needs to be done becuase
            // sites that are created from site templates (.stp) do not retain the templateid.
            oWeb.Properties.Add("STP_ID", strTemplate);
            oWeb.Properties.Update();
            oWeb.AllowUnsafeUpdates = false;

        });
    }
    catch (Exception ex)
    {
        throw ex;
    }
    finally
    {
        //dispose objects
        if (oWeb != null)
            oWeb.Dispose();

        if (oSite != null)
            oSite.Dispose();
    }
}

You need to create a new Web service within the Central Administration Web application ([12 hive]\AMDISAPI) and add a function that creates subsites.

Here's an example - the hstCreateSubSite function from the SharePoint for Hosters project:

/// <summary>
/// Method to create a Sub site for a site collection
/// </summary>
/// <param name="strSiteURL">url of the sitecollection i.e. "http://www.sitea.com"</param>
/// <param name="subsitePath">the path to the subsite i.e. inventory</param>
/// <param name="strTitle">sub site title</param>
/// <param name="strDesc">sub site description</param>
/// <param name="strTemplate">a valid templateID</param>
/// <param name="nLCID">the LCID for the language i.e. 1033 for english</param>
[WebMethod]
public void hstCreateSubSite(string strSiteURL, string subSitePath, string strTitle, string strDesc, string strTemplate, uint nLCID)
{

    SPSite oSite = new SPSite(strSiteURL); 
    SPWeb oSubSiteWeb = oSite.OpenWeb();

    SPWeb oWeb = null;

    if (String.IsNullOrEmpty(strDesc)) strDesc = null;
    if (String.IsNullOrEmpty(strTitle)) strTitle = null;

    try
    {
        // elevate permissions to allow user to create a new site.
        SPSecurity.RunWithElevatedPrivileges(delegate()
        {
            // the subsite will inherit permissions and will not convert the site if it exists
            oWeb = oSubSiteWeb.Webs.Add(subSitePath, strTitle, strDesc, nLCID, strTemplate, false, false);

            SPNavigationNodeCollection nodes = oSubSiteWeb.Navigation.TopNavigationBar;
            SPNavigationNode navNode = new SPNavigationNode(strTitle, subSitePath);
            nodes.AddAsLast(navNode);

            oWeb.Navigation.UseShared = true;

            // create entry in property bag to store template and url in the subsite.
            oWeb.AllowUnsafeUpdates = true;
            // add the Templateid to the property bag. This needs to be done becuase
            // sites that are created from site templates (.stp) do not retain the templateid.
            oWeb.Properties.Add("STP_ID", strTemplate);
            oWeb.Properties.Update();
            oWeb.AllowUnsafeUpdates = false;

        });
    }
    catch (Exception ex)
    {
        throw ex;
    }
    finally
    {
        //dispose objects
        if (oWeb != null)
            oWeb.Dispose();

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