Exemplo n.º 1
0
        //System must check for admin user and Admin role
        private void CheckAdminUserAndRolesExists()
        {
            String sysAdmin = "System Administrator";
            //String sysUser = "******";
            String sysDCEAdmin = "DCE Administrator";
            String sysDMSAdmin = "DMS Administrator";
            AuthenticationsAndAuthorizationsOperations aNaOps = new AuthenticationsAndAuthorizationsOperations();

            if (!Roles.RoleExists(sysAdmin))
            {
                Roles.CreateRole(sysAdmin);
                aNaOps.InsertRoleDescByRoleName(sysAdmin, systemCreatedAutomation);
            }
            //if (!Roles.RoleExists(sysUser)) {
            //    Roles.CreateRole(sysUser);
            //    aNaOps.InsertRoleDescByRoleName(sysUser, systemCreatedAutomation);
            //}
            if (!Roles.RoleExists(sysDCEAdmin))
            {
                Roles.CreateRole(sysDCEAdmin);
                aNaOps.InsertRoleDescByRoleName(sysDCEAdmin, systemCreatedAutomation);
            }
            if (!Roles.RoleExists(sysDMSAdmin))
            {
                Roles.CreateRole(sysDMSAdmin);
                aNaOps.InsertRoleDescByRoleName(sysDMSAdmin, systemCreatedAutomation);
            }

            String adminPassword = "******";
            MembershipCreateStatus createStatus;

            Membership.CreateUser("sysadmin", adminPassword, "*****@*****.**", null, null, true, null, out createStatus);
            if (createStatus == MembershipCreateStatus.Success)
            {
                aNaOps.InsertMembershipCommentByUserName("sysadmin", systemCreatedAutomation);
            }
            if (!Roles.IsUserInRole("sysadmin", sysAdmin))
            {
                Roles.AddUserToRole("sysadmin", sysAdmin);
            }
            if (!Roles.IsUserInRole("sysadmin", sysDCEAdmin))
            {
                Roles.AddUserToRole("sysadmin", sysDCEAdmin);
            }
            if (!Roles.IsUserInRole("sysadmin", sysDMSAdmin))
            {
                Roles.AddUserToRole("sysadmin", sysDMSAdmin);
            }

            //Membership.CreateUser("sysuser", adminPassword, "*****@*****.**", null, null, true, null, out createStatus);
            //if (createStatus == MembershipCreateStatus.Success) {
            //    aNaOps.InsertMembershipCommentByUserName("sysuser", systemCreatedAutomation);
            //}
            //if (!Roles.IsUserInRole("sysuser", sysUser)) { Roles.AddUserToRole("sysuser", sysUser); }
        }