예제 #1
0
        // newUser.Usr_Organize neend be set
        public CUserEntity CreateAdminlUser(CUserEntity newUser)
        {
            try
            {
                // Check privilege
                CACLEntity acl = new CACLEntity();
                acl.Acl_Operation = (int)ACLOPERATION.CRETAEORGANIZEADMIN;
                acl.Acl_Resource  = Usr_Organize;
                if (!CheckPrivilege(acl))
                {
                    throw new Exception("当前用户无创建管理员用户权限");
                }

                // create admin
                newUser.Usr_Type = (int)USERTYPE.ORGANIZEADMIN;
                CUserEntity user = CreateUser(newUser);

                // add acls to admin, organize acl, root dir acl
                COrganizeEntity organize = new COrganizeEntity(ConnString);
                organize = organize.Load(user.Usr_Organize);

/*
 *              CACLEntity acl1 = new CACLEntity(ConnString);
 *              acl1.Acl_CreateTime = DateTime.Now;
 *              acl1.Acl_Creator = Usr_Id;
 *              acl1.Acl_Operation = 0;
 *              acl1.Acl_Resource = organize.Org_Id;
 *              acl1.Acl_Role = user.Usr_Id;
 *              acl1.Acl_RType = (int)ACLROLETYPE.USERROLE;
 *              acl1.Acl_Id = acl1.Insert();
 */
                CACLEntity acl2 = new CACLEntity(ConnString);
                acl2.Acl_CreateTime = DateTime.Now;
                acl2.Acl_Creator    = Usr_Id;
                acl2.Acl_Operation  = (int)ACLOPERATION.WRITE;
                acl2.Acl_Resource   = organize.Org_Resource;
                acl2.Acl_Role       = user.Usr_Id;
                acl2.Acl_RType      = (int)ACLROLETYPE.USERROLE;
                acl2.Acl_Id         = acl2.Insert();

                CACLEntity acl3 = new CACLEntity(ConnString);
                acl3.Acl_CreateTime = DateTime.Now;
                acl3.Acl_Creator    = Usr_Id;
                acl3.Acl_Operation  = (int)ACLOPERATION.READ;
                acl3.Acl_Resource   = organize.Org_Resource;
                acl3.Acl_Role       = user.Usr_Id;
                acl3.Acl_RType      = (int)ACLROLETYPE.USERROLE;
                acl3.Acl_Id         = acl3.Insert();

                return(user);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #2
0
        public COrganizeEntity GetUserOrganize()
        {
            if (m_userOrganize != null)
            {
                return(m_userOrganize);
            }

            m_userOrganize = new COrganizeEntity(ConnString);
            m_userOrganize = m_userOrganize.Load(Usr_Organize);
            return(m_userOrganize);
        }