c# - Retrieving friendly name as claims user in SharePoint -


i'll explain i'm trying first. have claims identifier being passed in, example, 0e.t|saml provider|first.last@domain.local. want trim first.last@domain.local.

i aware can done simple string formatting, however, not flexible, if gets passed in don't expect, string formatting fail. it's more prone issues.

i want dynamically instead. here's i've tried.

attempting ensureuser claims identifier above, calling spuser.name:

spuser spuser = spcontext.current.web.ensureuser(spusername); username = spuser.name; 

i've tried following strings parameter in ensureuser, result in exception: the user specified logonname cannot found in active directory.

0e.t|saml provider|first.last@domain.local

saml provider|first.last@domain.local

first.last@domain.local

again, of fail.

another approach tried, using spclaimprovidermanager (pulled this blog):

spclaimprovidermanager mgr = spclaimprovidermanager.local; if (mgr != null && spclaimprovidermanager.isencodedclaim(username)) {     spusername = mgr.decodeclaim(spcontext.current.web.currentuser.loginname).value; } 

i want ensure i'm attempting decode actual claim, , not else, call isencodedclaim. this, however, returns false.

my questions:

1) doing wrong here results in both of these attempting failing? need differently them function properly?

2) there better method friendly claims user name without string parsing?

sigh somehow i: @ beginning of claims string being lopped off.

should have read i:0e.t|saml provider|first.last@domain.local. once added back, started functioning properly.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -