Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private string GetUsernameFromClaim(string claimsEncodedUsername)
- {
- using (new SPMonitoredScope("GetUsernameFromClaim method start"))
- {
- try
- {
- SPClaimProviderManager spClaimProviderManager = SPClaimProviderManager.Local;
- if (spClaimProviderManager != null)
- {
- if (SPClaimProviderManager.IsEncodedClaim(claimsEncodedUsername))
- {
- // return the normal domain/username without any claims identification data
- return spClaimProviderManager.ConvertClaimToIdentifier(claimsEncodedUsername);
- }
- }
- }
- catch (Exception ex)
- {
- // You should handle any exceptions in here instead of ignoring them!
- // Logger.Log("An exception occured in the GetUsernameFromClaim() method");
- return claimsUsername; // Or just return the original username.
- }
- // Return the original username value if it couldn't be resolved as a claims username
- return claimsUsername;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement