我在 office 365 上创建了安全组,并且在我的 sharepoint 站点上也有组。我想以编程方式将 o365 上的安全组添加到共享点站点组。
请你帮助我好吗?
谢谢
我在 office 365 上创建了安全组,并且在我的 sharepoint 站点上也有组。我想以编程方式将 o365 上的安全组添加到共享点站点组。
请你帮助我好吗?
谢谢
答案取决于您要以编程方式执行此操作的平台。我假设您使用的是 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;
}
}