Example #1
0
        private static bool IsUserInSecurityGroup(BaseSecurityGroup group, Workflow workflow, WorkflowStep step, string EntityID, string UserName)
        {
            bool retVal = false;


            switch (group.Type.ToLower())
            {
            case "everyone":
                retVal = true;
                break;

            case "user":
                UserSecurityGroup userGroup = (UserSecurityGroup)group;
                if (!String.IsNullOrEmpty(userGroup.User))
                {
                    if (userGroup.User.ToLower() == UserName)
                    {
                        retVal = true;
                    }
                }
                break;



            case "role":

                RoleSecurityGroup roleGroup = (RoleSecurityGroup)group;

                retVal = AuthorizationService.GetInstance().AuthorizationProvider.IsInRole(roleGroup.Role);


                break;

            case "dynamic":
                WorkflowDynamicSecurityGroup dynamicGroup = (WorkflowDynamicSecurityGroup)group;
                DataTable users = WorkflowDynamicSecurityGroup.GetUsers(dynamicGroup, workflow, step, EntityID, UserName);

                if (users.Rows.Count > 0)
                {
                    retVal = true;
                }

                break;
            }

            return(retVal);
        }
Example #2
0
        public static bool IsUserInSecurityGroup(BaseSecurityGroup group, string UserName)
        {
            bool retVal = false;
            App  app    = Configuration.GetInstance().App;

            switch (group.Type.ToLower())
            {
            case "everyone":
                retVal = true;
                break;

            case "user":
                UserSecurityGroup userGroup = (UserSecurityGroup)group;
                if (!String.IsNullOrEmpty(userGroup.User))
                {
                    if (userGroup.User.ToLower() == UserName)
                    {
                        retVal = true;
                    }
                }
                break;



            case "role":
                throw new NotSupportedException();
                //RoleSecurityGroup roleGroup = (RoleSecurityGroup)group;
                //RoleDB roleDB = new RoleDB();
                //DataTable role = roleDB.GetRoleByUserNameAndRoleName(null, app.AuthorizationMode.SupportsMultipleRoles, UserName, roleGroup.Role);
                //if (role.Rows.Count > 1)
                //{
                //    retVal = true;
                //}
                break;
            }

            return(retVal);
        }