Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 25064

Granting access to claims based user programmatically

$
0
0

HI,

How to add claims based user to the sharepoint site programmatically?

I have tried this:

 string struserLanID = Convert.ToString(CurrentListItem[userLanId]);
  SPUser osuser =      oSPWeb.EnsureUser(struserLanID);
struserLanID = osuser.ToString();

  if (!string.IsNullOrEmpty(struserLanID))
                {
                    //Grant permission 
 SPRoleAssignment oSPRoleAssignmentManager = new SPRoleAssignment(struserLanID,"", "", "");
                    oSPRoleAssignmentManager.RoleDefinitionBindings.Add(oSPRoleDefinition);

CurrentListItem.RoleAssignments.Add(oSPRoleAssignmentManager);
                }
I get the userLanID as "domain\username". However, I want to convert it to sp2013 claims based user and add it. By giving access to "domain\username", the user is not able to access. I want to convert the user to "

i:0#.w|domain\username" and then add the user. How to achieve it?

Thanks



Viewing all articles
Browse latest Browse all 25064

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>