I am creating a Roles impersonation developer tool for an intranet site to allow developers to act quickly like any Role as needed. Specific Roles Developer, Team Lead, Team Member, Engineering, Marketing, Guest , and the tool on the web page makes a web api call to add or remove Claim ... well, I can add, but I can not find where .RemoveClaim(claim) or .TryRemoveClaim(claim) to get this working. Do I have to create my own application manager to get this functionality, or am I missing something?
I watched System.Security.Claims , and almost everything else works very simply and there is no link that I need to work hard to do what I need.
I am using VS 2013 / Web Api2 with .NET 4.5.1.
The website side just uses a simple ajax call for the PUT and DELETE functions until I get it to work the way I want. From Controller, my cs code looks like this:
public void Put(int id, [FromBody]string role) { if (FindClaim(role) != null) return; var user = HttpContext.Current.User as ClaimsPrincipal; if (user == null) return; var claimId = new ClaimsIdentity(); claimId.AddClaim(new Claim(ClaimTypes.Role, role)); user.AddIdentity(claimId); }
PUT works fine, the problem is with the DELETE code part of my code ... I want to use the code user.RemoveClaim(claim); or something like this ... I don’t understand why I can’t comply with MSDN, and I can’t find any sample code to remove the claim.
c # asp.net-web-api wif claims-based-identity
Greg Mason Mar 21 '14 at 22:36 2014-03-21 22:36
source share