Esempio n. 1
0
        // AddUserToCardHolderRole


        public void AddUserToCardHolderRole(String username)
        {
            IRolesDAO RoleRepository = new RolesDAO();

            if (!RoleRepository.RoleExists(CardHolderRole, _provider.ApplicationName))
            {
                throw new Exception("Missing Role - " + CardHolderRole);
            }

            IUserInRolesDAO UsersInRoles = new UserInRolesDAO();

            UsersInRoles.AddUserToRole(username, CardHolderRole, _provider.ApplicationName);
        }
Esempio n. 2
0
        void ICardHolderService.CreateSystemAdmin(String UserName, String Password, String SecondPassword)
        {
            MembershipCreateStatus status;

            if (String.IsNullOrEmpty(UserName))
            {
                throw new ArgumentException("Value cannot be null or empty.", "userName");
            }
            if (String.IsNullOrEmpty(Password))
            {
                throw new ArgumentException("Value cannot be null or empty.", "password");
            }
            if (String.IsNullOrEmpty(SecondPassword))
            {
                throw new ArgumentException("Value cannot be null or empty.", "email");
            }



            // first make sure that super user role exists
            IRolesDAO RoleService = new RolesDAO();

            RoleService.InsureSuperUserRoleExists(_provider.ApplicationName);

            // then add the super user to the list of users

            MembershipUser user = _provider.CreateUser(UserName, Password, UserName + "@system",
                                                       null, null, true, null, out status);

            if (user == null)
            {
                throw new Exception("Problems in creating user");
            }


            // then add super user to users in roles

            IUserInRolesDAO UserInRoleRepository = new UserInRolesDAO();

            UserInRoleRepository.AddUserToRole(UserName, "SystemAdministrator", _provider.ApplicationName);

            // then save the second password by creating a new user with name "secondPassword"

            user = _provider.CreateUser(UserName + "SecondPassword", SecondPassword, UserName + "*****@*****.**",
                                        "",   //WebData.passwordQuestion,
                                        "",   //WebData.passwordAnswer,
                                        true, //WebData.isApproved,
                                        null, //WebData.providerUserKey,
                                        out status);
        }
        bool ICLerkService.DeleteClerk(int ClerkID)
        {
            using (var GiftEntity = new GiftEntities())
            {
                IClerkDAO ClerkData = new ClerkDAO();
                Clerk     tClerk    = ClerkData.GetClerk(ClerkID);

                IUserDAO UserData = new UserDAO();
                UserData.DeleteUser(tClerk.UserName);
                IUserInRolesDAO UserRolesData = new UserInRolesDAO();
                UserRolesData.DeleteUserFromRole(tClerk.UserName);

                ClerkData.DeleteClerk(ClerkID);
            }

            return(true);
        }
        // AddUserToClerkRole

        public void AddUserToClerkRole(String username)
        {
            MembershipProvider _provider;

            _provider = Membership.Providers["GiftUserMembershipProvider"];

            IRolesDAO RoleDAO = new RolesDAO();

            if (!RoleDAO.RoleExists(ClerkRole, _provider.ApplicationName))
            {
                throw new Exception("Missing Role - " + ClerkRole);
            }

            IUserInRolesDAO UsersInRoles = new UserInRolesDAO();

            UsersInRoles.AddUserToRole(username, ClerkRole, _provider.ApplicationName);
        }
Esempio n. 5
0
        // in order to run, the system needs to have been initialized
        bool ICardHolderService.VerifySystemInitialized()
        {
            IUserInRolesDAO UserRoleService = new UserInRolesDAO();

            return(UserRoleService.VerifySuperUserExists(_provider.ApplicationName));
        }