Wednesday, March 16, 2011

Awkward Usernames Courtesy of Claims Authentication (FBA)

Who’s i:0#.f|membership_providerName|userName?

If you’re one of the many people who have set up Forms Based Authentication in SharePoint 2010, you’ve likely enjoyed dealing with the awkward usernames that can come with claims authentication and FBA (Forms Based Authentication).
In a recent engagement, we’d provisioned an ASP.NET Membership schema (aspnet_regsql.exe), populated it with a stock SQLMembershipProvider and then added the users to the site collection using the Site Settings->People and Groups screens.
What we ended up with, were a lot of SPUsers with "unfriendly" SPUser.Name properties set. Since the Name field wasn’t assigned it ended up getting set to the equivalent of the SPUser.LoginName property which looks a lot like:
i:0#.f|fba|administrator
The problem with leaving these cryptic display names in their native format is that they can seep all over a farm. Not only will they show up in stock SharePoint controls that display user names, but those same display names will also start to show up in other service applications like search.
There's also the fact that your users will likely ask you to set them to something more sensible.

Resting the SPUser.DisplayName Property

Assuming you have some other name that you’d prefer instead of the awkward native claims format, you can explicitly set these display names by using either PowerShell or the stock SharePoint API.
Below are two examples, both involve you iterating over everyone in the authentication store (think SQL, LDAP, AD, etc…) and updating the SPUser.Display/Name property after fetching the SPUser out of the site collection. See below:


PowerShell
$user = Get-SPUser -Web "http://wss2k10tholmes:81" -Identity "i:0#.f|providerName|userName"
$user.DisplayName = "FriendlyName";
$user.Update();
C# (API)
//We use ensure so that the given user will be added if they don't exist. They need to be resolved
//via their claims name.
SPUser spUser = web.EnsureUser(string.Format("i:0#.f|providerName|{0}", fbaUser.UserName));
spUser.Name = "FriendlyName";
spUser.Update();

Alternatives

You don’t necessarily need to go through the API or PowerShell, if you have a connection to an LDAP store or a BCS connection to your auth store. You can also map the properties yourself and leave it to the User Profile Synchronization service. That being said, if you’re dependent on BCS then you’ll also need to have SharePoint Enterprise Server license which isn’t available to all customers.
Once you’re done you should be
Administrator Claims FBA username able to visit any of the users in your site collection and see their “Name” property set to something that is less likely to confuse your user base. Once the value is set, it helps to make sure that it doesn’t get stomped with any User Profile Synchronization (UPS) that may be in place in your farm.

Hope that Helps,

Tyler

30 comments:

sidahmed said...
This comment has been removed by the author.
sidahmed said...

Many thanks Tyler, it was very helpfull.

Shan Kane said...

Hello, I was going thru. your" TCP Chimney" issue on the SQL Server. Truly a great post. Thanks a bunch for sharing. CAn you please shed more light on your first few steps to reach to that conclusion.
Thank You man!!
-Shan

Tyler Holmes said...

Hey Shan,

Is your question about this post (Claims Auth and FBA), or is it about the TCP chimney issue?

Best,
Tyler

shobs said...

How do I change the display name of 1000+ users I have.

shobs said...

How do I change the display name of 1000+ users I have.

Anonymous said...

Hello Tyler,

Would you be so kind as to direct me how to loop foreach $user in the site collection and have them all changed to user friendly names?

shameej said...

Thanks for the solution ....
It worked perfectly....

Sqiar said...

Thanks for the post, In this complex environment business need to present there company data in meaningful way.So user easily understand it .Sqiar (http://www.sqiar.com/why-data-visualization/) which is in UK,provide services like Tableau and Data Warehousing etc .In these services sqiar experts convert company data into meaningful way.

lee woo said...

I've always been a loner, and I've spent most of my life as a single person. See the link below for more info.

#loner
www.ufgop.org

Pavel Co Ebele said...

Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai. or learn thru Dot Net Training in Chennai. Nowadays Dot Net has tons of job opportunities on various vertical industry.
or Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry.

sathish said...

After reading this web site I am very satisfied simply because this site is providing comprehensive knowledge for you to audience.
Thank you to the perform as well as discuss anything incredibly important in my opinion. We loose time waiting for your next article writing in addition to I beg one to get back to pay a visit to our website in



Selenium training in bangalore
Selenium training in Chennai
Selenium training in Bangalore
Selenium training in Pune
Selenium Online training

Chris Hemsworth said...

The article is so informative. This is more helpful for our
Learn best software testing online certification course class in chennai with placement
Best selenium testing online course training in chennai
Best online software testing training course institute in chennai with placement
Thanks for sharing.

Madhu Balan said...

Great post!
Thanks for sharing this list!
It helps me a lot finding a relevant blog in my niche!
Java Training in Chennai
Java Training in Coimbatore
Java Training in Bangalore

Riya Raj said...

The way you have conveyed your blog is more impressive.... good blog...
JAVA Training in Chennai
Best JAVA Training institute in Chennai
JAVA Course
advanced java training in chennai
JAVA Training in Tambaram
java training in Guindy
Python Training in Chennai
Big data training in chennai
SEO training in chennai
Selenium Training in Chennai

Nikhil N said...

Nice blog....waiting for next update....
Struts Training in Chennai
Struts Training center in Chennai
Struts course in Chennai
Struts Training in Velachery
Struts Training in Tambaram
Wordpress Training in Chennai
SAS Training in Chennai
Spring Training in Chennai
Photoshop Classes in Chennai
DOT NET Training in Chennai

nadiya said...

I really liked and I got some innovative ideas for improving my thoughts from well defined content.
IELTS Coaching in Chennai
IELTS Coaching centre in Chennai
French Classes in Chennai
pearson vue test center in chennai
Informatica Training in Chennai
Data Analytics Courses in Chennai
IELTS Coaching in OMR
IELTS Coaching in Porur

chandhran m said...

Thanks for sharing your great ideas with us and update more informations.
Best Aviation Academy in Chennai
Air Hostess Academy in Chennai
Airline Courses in Chennai
Ground Staff Training in Chennai
Airport Management Courses in Bangalore
Airport Management Courses in Chennai
Air Hostess Academy in Chennai
Air Hostess Course in Mumbai
Ground staff training in Bangalore
Best Aviation Academy in Chennai

Anjudevan said...

Awesome Article...Thanks for sharing...waiting for next update...
Wordpress Training in Chennai
Wordpress Training Chennai
Wordpress Training Institutes in Chennai
wordpress training in Thiruvanmiyur
Wordpress Training in Velachery
Struts Training in Chennai
clinical sas training in chennai
Spring Training in Chennai
Photoshop Classes in Chennai
LoadRunner Training in Chennai

Kayal m said...

This article is increasing the interest to learn more about this topic. Continue the sharing your new updates, regularly for my future.
Linux Training in Chennai
best linux training institute in chennai
Social Media Marketing Courses in Chennai
Placement Training in Chennai
Soft Skills Training in Chennai
Oracle Training in Chennai
Pega Training in Chennai
Tableau Training in Chennai
Unix Training in Chennai
Linux Training in Porur
Linux Training in Anna Nagar


silakarim said...
This comment has been removed by the author.
manjuragul said...

The concept you are saying is good. I was so happy after reading this article. Thankyou so much for good article.
IELTS Coaching in anna nagar
IELTS Coaching in Chennai
IELTS Coaching in OMR
AngularJS Training in OMR
DOT NET Training in T nagar
IELTS Coaching in Tnagar
Big data training in annanagar
Tally Course in OMR

dineshkumar said...

Great info. The content you wrote is very interesting to read. This will be loved by all age groups.
DevOps Training in Chennai
Best DevOps Training in Chennai
DevOps Training institute in Chennai
Azure Training in Chennai
VMware Training in Chennai
RPA Training in Chennai
DevOps Training in Velachery
DevOps Training in Tambaram
DevOps Training in Adyar
DevOps Training in Vadapalani

Anbarasan14 said...

This was helpful to me thanks for sharing this useful information. Kindly continue the work.
Education Franchise India
Spoken English Franchise
Franchise For Spoken English Classes
Top Education Franchise In India
Best Education Franchise In India
Computer Education Franchise
Education Franchise India
Computer Center Franchise
Education Franchise Opportunities In India

cynthiawilliams said...

Awesome post with lots of data and I have bookmarked this page for my reference. Share more ideas frequently.
Salesforce Training in Chennai
best salesforce training in chennai
salesforce admin training in chennai
Salesforce crm Training in Chennai
AngularJS Training in Chennai
ccna course in Chennai
ReactJS Training in Chennai
Tally course in Chennai
Salesforce Training in Velachery
Salesforce Training in T Nagar

sanjandevan said...

Valuable one...thanks for sharing...
javascript training in chennai
javascript course in chennai
javascript training institute in chennai
javascript training in Thiruvanmiyur
javascript training in Tambaram
javascript training in chennai
core java training in chennai
Photoshop Classes in Chennai
Manual Testing Training in Chennai
Drupal Training in Chennai

shwethapriya said...

Interesting blog. Got a lotb of information about this technology.
Spoken English Classes in Chennai
English Coaching Classes in Chennai
IELTS Training in Chennai
Japanese Language Course in Chennai
TOEFL Training in Chennai
French Language Classes in Chennai
Spoken English Classes in Porur
Spoken English Classes in Adyar

vinudevan said...

Valuable one...thanks for sharing...
Hibernate Training in Chennai
Spring Hibernate Training
Spring and Hibernate Training
Hibernate Training in OMR
hibernate training in Porur
Spring Training in Chennai
clinical sas training in chennai
DOT NET Training in Chennai
QTP Training in Chennai
LoadRunner Training in Chennai

divi said...

thanks for your information really good and very nice web design company in velachery

tech updates said...

Good Article
devops training in bangalore
hadoop training in bangalore
iot training in bangalore
machine learning training in bangalore
uipath training in bangalore