c# - How to find just one group a user is logged in as -


i have following code displays each group user logged in:

protected void page_load(object sender, eventargs e)     {         groups();     }      public arraylist groups()     {         arraylist groups = new arraylist();          foreach (system.security.principal.identityreference group in              system.web.httpcontext.current.request.logonuseridentity.groups)         {              groups.add(group.translate(typeof                  (system.security.principal.ntaccount)).tostring());          }         (int = 0; < groups.count; i++)         {             messagebox.show(groups[i].tostring() + "");         }           return groups;     } 

some of groups displays are:

builin\administrators iis_usrs tmg\it members tmg\domain users 

how check if user in tmg\it members group only?

i tried following failed because group didn't have \:

for (int = 0; < groups.count; i++)         {             messagebox.show(groups[i].tostring() + "");             string t = groups[i].tostring().split('\\')[0];             string y = groups[i].tostring().split('\\')[1];             messagebox.show(t);             messagebox.show(y);         } 

i think want this:

for (int = 0; < groups.count; i++){   if ( groups[i].tostring() == @"tmg\it members" )    {      ...    // true...   } } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -