c# - User not found when adding an AD group to an SP group -


i trying run code suggested here: https://sharepoint.stackexchange.com/questions/72431/what-is-the-correct-way-to-add-an-ad-group-to-an-sp-group-with-permissions

the ensureuser line works, on web.users line, says user not found.

var membersgroup = web.sitegroups.getbyname(string.concat(web.title, " ", "members"));  if (!string.isnullorempty(xlosgroupname)) {     string xlosgroupnamewithdomain = string.concat(domainname, @"\", xlosgroupname);     web.ensureuser(xlosgroupnamewithdomain);     var adlosgroup = web.users[xlosgroupnamewithdomain];     membersgroup.users.add(adlosgroup.loginname, string.empty, adlosgroup.name, adlosgroup.notes);     sproledefinition contribute = web.roledefinitions.getbytype(sproletype.contributor);     sproleassignmentcollection roleassignments = web.roleassignments;     sproleassignment roleassignment = new sproleassignment(xlosgroupnamewithdomain, string.empty, string.empty, string.empty);     sproledefinitionbindingcollection roledefbindings = roleassignment.roledefinitionbindings;     roledefbindings.add(contribute);     roleassignments.add(roleassignment); } 

you can try users web specified using following method: web.allusers

wish can you.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -