【问题标题】:Add security group to sharepoint group programmatically on Sharepoint Online在 Sharepoint Online 上以编程方式将安全组添加到 sharepoint 组
【发布时间】:2014-01-04 00:11:18
【问题描述】:

我在 Office 365 上创建了安全组,并且在我的共享点站点上也有组。我想以编程方式将 o365 上的安全组添加到 sharepoint 站点组。

你能帮帮我吗?

谢谢

【问题讨论】:

  • 您想使用 CSOM 来执行此操作吗?

标签: sharepoint-2013 office365 sharepoint-online


【解决方案1】:

答案取决于您要以编程方式执行此操作的平台。我假设您使用的是 PowerShell,在这种情况下,您最好的选择是 Add-SPOUser cmdlet,它“将现有 Office 365 用户或 Office 365 安全组添加到 SharePoint 组”。

以下示例假设您使用的是 PowerShell:

$SecGroupName = "TestSecurityGroup"        # The security group DisplayName
$SPOGroupName = "TestSharePointGroup"      # The SharePoint Online group

# Get the SharePoint site
$SPOSite = Get-SPOSite "https://contoso.sharepoint.com"

# Add the security group as a member of the SharePoint Online group
Add-SPOUser -Site $SPOSite -LoginName $SecGroupName -Group $SPOGroupName

一些您可能会觉得有用的链接:

(请注意,Office 365 中的用户和组实际上是 Azure Active Directory 用户和安全组,这就是我提供 Azure AD PowerShell cmdlet 链接的原因。)

【讨论】:

  • 感谢菲利普的回答。我是用 c# 做的。
  • 如果您以不同的方式解决它,您应该发布您的解决方案并将其标记为已回答。 (或者如果这是答案,您也可以将其标记为已解决。:))
【解决方案2】:
public Group createSharepointGroup(string Name, string description)
    {
        try
        {
            GroupCreationInformation groupInfo = new GroupCreationInformation();
            groupInfo.Description = description;
            groupInfo.Title = Name;


            Group group = currentWeb.SiteGroups.Add(groupInfo);

            clientContext.Load(group);
            clientContext.ExecuteQuery();

            return group;

        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.InnerException.ToString());
            return null;
        }

    }

【讨论】:

    猜你喜欢
    • 2011-06-10
    • 1970-01-01
    • 2020-01-27
    • 2018-11-13
    • 1970-01-01
    • 2012-08-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多