sharepoint ECMA 添加User到Site组

 1         self.GetGroup = function (subSiteurl) {
 2             var subClientContent = new SP.ClientContext(subSiteurl);  //获取当前站点
 3             var groupCollection = subClientContent.get_web().get_siteGroups();//获取当前站点中所有的Group
 4             var ownersGroup = groupCollection.getByName("SpeadTrum Owners");//获取指定的Group
 5             //get all account user
 6             $("div[id$='peUsers_upLevelDiv'] div").each(function (i, value) {   //获取PeopleEditor里所有选择的人员
 7                 if (value.id != null) {
 8                     if (value.id == 'divEntityData' && value.parentElement.title != null) {
 9                         var ouser = "";
10                         var userCreateInfo = new SP.UserCreationInformation();
11                         userCreateInfo.set_loginName(value.parentElement.title.replace("\\", "\\\\"));
12                         userCreateInfo.set_title(value.parentElement.textContent);
13                         ouser = ownersGroup.get_users().add(userCreateInfo);
14                         subClientContent.load(ouser);
15                         subClientContent.executeQueryAsync();
16                     }
17                 }
18             });
19         }//get group id
当我们获取到要添加的人员名称"accoumt\loginName"的时候,需要转换成"accoument\\loginName",否则会报此这样一个error:The user does not exist or is not unique.

当然报此错误还有一种我已知的错误就是认证方式。如果是认证方式不是是windows NTLM方式,就会出现这个错误。详细的请见:下面这个篇博客http://www.cnblogs.com/wsdj-ITtech/archive/2012/08/02/2425038.html
 
  

转载于:https://www.cnblogs.com/lynn-lin/p/3775325.html

猜你喜欢

转载自blog.csdn.net/weixin_33940102/article/details/93639898