Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd claims to an already made token
    text
    copied!<p>I am using the CustomToken example from msdn and messing around with an idea of adding new claims and rebuilding a previously made token or breaking it apart, adding new values and making a new token. I have tried adding new claims to the principal in the relyingparty which didn't work, I tried to rebuild the token and got an error on CustomeSecurityTokenServiceConfiguration 'An item with the same key has already been added' and I have tried close to a dozen different ways that gave no results. Any ideas on how this can be done or am I looking for something that doesn't exist? </p> <p>Attempt on relying default</p> <pre><code> if (claimsPrincipal != null) { ClaimsIdentity identity = claimsPrincipal.Identity as ClaimsIdentity; BootstrapContext bootstrapContext = identity.BootstrapContext as BootstrapContext; var newclaims = new List&lt;Claim&gt; { new Claim(ClaimTypes.PostalCode,"56789") }; foreach(Claim claim in claimsPrincipal.Claims) { newclaims.Add(claim); } var claimsIdentity = new ClaimsIdentity(newclaims, "Name", "UserName", ClaimTypes.Role); ClaimsPrincipal pass = new ClaimsPrincipal(claimsIdentity); FederatedPassiveSecurityTokenServiceOperations.ProcessRequest(Request, pass, SimpleWebToken.CustomSecurityTokenServiceConfiguration.Current.CreateSecurityTokenService(), Response); //SimpleWebToken.SimpleWebTokenHandler Added = new SimpleWebToken.SimpleWebTokenHandler(); //Added.AddtoCreatedToken(pass); </code></pre> <p>}</p> <p>I have also tried adding my own create token which is</p> <pre><code>public SecurityToken AddtoCreatedToken(ClaimsPrincipal claimsPrincipal) { if (claimsPrincipal == null) { throw new ArgumentNullException("tokenDescriptor"); } NameValueCollection properties = new NameValueCollection(); foreach (Claim claim in claimsPrincipal.Claims) { properties.Add(claim.Type, claim.Value); } SimpleWebToken token = new SimpleWebToken(properties); return token; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload