【发布时间】:2020-01-04 05:39:22
【问题描述】:
我正在尝试使用 CSOM 将用户添加到 SharePoint 网站,但我收到一条说明“用户不存在或不是唯一的”我的登录名有问题吗?。 “anil@developer19.onmicrosoft.com”是该组织的活跃用户。
using System;
using System.Security;
using Microsoft.Online.SharePoint.TenantAdministration;
using Microsoft.SharePoint.Client;
namespace CreateSiteCollections
{
class Program
{
static void Main(string[] args)
{
//Opens the Admin URL
using (ClientContext ctx1 = new ClientContext("https://developer19.sharepoint.com/sites/codesite"))
{
//Authenticating with Tenant Admin
SecureString passWord = new SecureString();
foreach (char c in "Password".ToCharArray())
passWord.AppendChar(c);
ctx1.Credentials = new SharePointOnlineCredentials("kailash@developer19.onmicrosoft.com", passWord);
GroupCollection cg = ctx1.Web.SiteGroups;
Group oGroup = cg.GetById(14);
UserCreationInformation user = new UserCreationInformation();
user.Email = "anil@developer19.onmicrosoft.com";
user.LoginName = "developer19/anil";
user.Title = "Anil";
User oUser = oGroup.Users.Add(user);
ctx1.ExecuteQuery();
}
}
}
}
【问题讨论】:
标签: c# .net sharepoint office365 csom