我在Office 365上创建了安全组,并且我的SharePoint站点上也有组。我想以编程方式将o365上的安全组添加到SharePoint站点组。在Sharepoint Online上以编程方式将安全组添加到Sharepoint组
你能帮我吗?
谢谢
我在Office 365上创建了安全组,并且我的SharePoint站点上也有组。我想以编程方式将o365上的安全组添加到SharePoint站点组。在Sharepoint Online上以编程方式将安全组添加到Sharepoint组
你能帮我吗?
谢谢
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;
}
}
答案取决于你想用这个编程方式做什么平台。我假设您使用的是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命令。)
谢谢你的答案philippe。我用c#做了。 –
如果您以不同的方式解决问题,您应该发布解决方案并将其标记为已回答。 (或者如果这是答案,你可以标记它也解决了:)) –
你要做到这一点使用CSOM? –
我想用c# –