Adding users programmaticaly on a SharePoint 2010 claims based site (extranet)


In SharePoint 2007 under classic forms based authentication you had this line of code:
 
userLogin = "sqlMembership:user@domain.com";
spWeb.SiteUsers.Add(userLogin, userEmail, userEmail, string.Empty);
 
In SharePoint 2010 this is going to be:
 
userLogin = "i:0#.w|sqlMembership|user@domain.com";
spWeb.SiteUsers.Add(userLogin, userEmail, userEmail, string.Empty);
 
"i": the defaultname for ClaimsBased Authentication
"0#.": no clue 🙂 
"w": Windows Based
"f": Forms Based
"sqlMembershop": the name of your custom provider
Advertisements
This entry was posted in Sharepoint. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s