【发布时间】:2014-01-04 00:11:18
【问题描述】:
我在 Office 365 上创建了安全组,并且在我的共享点站点上也有组。我想以编程方式将 o365 上的安全组添加到 sharepoint 站点组。
你能帮帮我吗?
谢谢
【问题讨论】:
-
您想使用 CSOM 来执行此操作吗?
标签: sharepoint-2013 office365 sharepoint-online
我在 Office 365 上创建了安全组,并且在我的共享点站点上也有组。我想以编程方式将 o365 上的安全组添加到 sharepoint 站点组。
你能帮帮我吗?
谢谢
【问题讨论】:
标签: sharepoint-2013 office365 sharepoint-online
答案取决于您要以编程方式执行此操作的平台。我假设您使用的是 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 链接的原因。)
【讨论】:
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;
}
}
【讨论】: