示例#1
0
        public static bool IsCurrentUserInRole(string role)
        {
            //Determine if the current user is in the specified role
            bool inRole = false;
            RoleServiceClient client = new RoleServiceClient();

            try {
                inRole = client.IsCurrentUserInRole(role);
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(inRole);
        }
示例#2
0
 public static string[] GetRolesForCurrentUser()
 {
     //Get all roles for the current user
     try {
         _Client = new RoleServiceClient();
         if (_roles == null)
         {
             _roles = _Client.GetRolesForCurrentUser();
             _Client.Close();
         }
     }
     catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException(te.Message); }
     catch (FaultException fe) { _Client.Abort(); throw new ApplicationException(fe.Message); }
     catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException(ce.Message); }
     return(_roles);
 }