c# - GroupPrincipal throws argument exception -


i have static method validate, if user in adgroup or not.
method looks like:

 public static bool isuserinadgroup(string groupname, string name)         {             if (string.isnullorempty(groupname) || string.isnullorempty(name))             {                 return false;             }              // create domain context             var ctx = new principalcontext(contexttype.domain, configuration.getvalue("ad"));              // find group in question             var group = groupprincipal.findbyidentity(ctx, groupname);              // find user             var user = userprincipal.findbyidentity(ctx, name);                if (user != null && group != null)             {                 if (user.ismemberof(group))                 {                     return true;                 }                  return false;             }              return false;          } 

i wrote unittest method , works fine. when call method wpf application, i've got exception: enter image description here

what doing wrong?


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -