Advertisement
Guest User

Untitled

a guest
Jan 29th, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. private string GetUsernameFromClaim(string claimsEncodedUsername)
  2. {
  3. using (new SPMonitoredScope("GetUsernameFromClaim method start"))
  4. {
  5. try
  6. {
  7. SPClaimProviderManager spClaimProviderManager = SPClaimProviderManager.Local;
  8. if (spClaimProviderManager != null)
  9. {
  10. if (SPClaimProviderManager.IsEncodedClaim(claimsEncodedUsername))
  11. {
  12. // return the normal domain/username without any claims identification data
  13. return spClaimProviderManager.ConvertClaimToIdentifier(claimsEncodedUsername);
  14. }
  15. }
  16. }
  17. catch (Exception ex)
  18. {
  19. // You should handle any exceptions in here instead of ignoring them!
  20. // Logger.Log("An exception occured in the GetUsernameFromClaim() method");
  21. return claimsUsername; // Or just return the original username.
  22. }
  23.  
  24. // Return the original username value if it couldn't be resolved as a claims username
  25. return claimsUsername;
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement