How to get domain\user notation of an account if it is in claim format


You can convert claim format into domain\user format  ;

string Username;
SPClaimProviderManager
mgr = SPClaimProviderManager.Local;
if (mgr != null && SPClaimProviderManager.IsEncodedClaim(SPContext.Current.Web.CurrentUser.LoginName))
           {
Username= mgr.DecodeClaim(SPContext.Current.Web.CurrentUser.LoginName).Value;
           }
else
          {
Username= SPContext.Current.Web.CurrentUser.LoginName;
}

 

More details of the SPClaimProviderManager methods:
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.claims.spclaimprovidermanager_methods.aspx

 

 

Advertisement

About bpostaci
Escalation Engineer in Microsoft.

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 )

Connecting to %s

%d bloggers like this: