c# - IsInRole Getting New Security Token -


i'm using windowsprincipal's isinrole method check group memberships in wpf , winforms apps. i'm generating identity token can ad user (not user who's logged computer--depending on i'm doing don't authenticate, use basic informational level token (i think proper name "identity token").

the first time code run on particular computer operating system generates identity token user specified. token used isinrole function validate group memberships. it's fast it. however, subsequent calls create windowsidentity/windowsprincipal reference existing token instead of creating new one. way know how update token log out of computer or reboot (which clears token cache). know better way reset cached identity tokens?

example code c#:

using system.security.principal; windowsidentity impersonationlevelidentity = new windowsidentity("some_userid_that_isn't_me", null); windowsprincipal identitywindowsprincipal = new windowsprincipal(impersonationlevelidentity); if (identitywindowsprincipal.isinrole("an_ad_group")) { ... 

vb:

imports system.security.principal dim impersonationlevelidentity = new windowsidentity("some_userid_that_isn't_me", nothing) dim identitywindowsprincipal = new windowsprincipal(impersonationlevelidentity) if identitywindowsprincipal.isinrole("an_ad_group") then... 

not sure if may resolve issue, try calling dispose method of windowsidentity class either directly or indirectly.

using (windowsidentity impersonationlevelidentity = new windowsidentity("some_userid_that_isn't_me", null)) {   // code } 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -