2013-12-16 50 views

回答

0
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; 
     } 

    } 
0

答案取决于你想用这个编程方式做什么平台。我假设您使用的是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命令。)

+0

谢谢你的答案philippe。我用c#做了。 –

+0

如果您以不同的方式解决问题,您应该发布解决方案并将其标记为已回答。 (或者如果这是答案,你可以标记它也解决了:)) –

相关问题