我在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# –