Esempio n. 1
0
        public void LegalAddUserTest()
        {
            InitAdmins();

            var mainApp = this.CreateDefaultApp();

            var mainRole = this.CreateDefaultRoleWithMembers(this.GetSCUsersByCodeNames("wanglch"));

            var mainOrg = base.GetOrganizationByCodeName("costEngineer");

            var testOrg = this.NewObject <PC.SCOrganization>("测试组织");

            Facade.AddOrganization(testOrg, mainOrg);
            base.SetContainerMemberAndPermissions(testOrg, mainRole, new string[] { "AddChildren" });

            PC.SCUser user = NewObject <PC.SCUser>("测试用户");

            SetCurrentPrincipal(this.GetUserByCodeName("wanglch"));

            FacadeWithAcl.AddUser(user, testOrg);

            var actual = GetSCUserByCodeName(user.CodeName);

            Assert.IsNotNull(actual);
        }
Esempio n. 2
0
        public OguObjectCollection <IGroup> GetGroupsOfUser(IUser user)
        {
            PC.SCUser objUser = (PC.SCUser)PC.Adapters.SchemaObjectAdapter.Instance.Load(user.ID);

            var groups = objUser.CurrentGroups;

            var groupIds = groups.ToIDArray();

            return(this.GetObjects <IGroup>(SearchOUIDType.Guid, groupIds));
        }
Esempio n. 3
0
        public void AdminAddUserTest()
        {
            InitAdmins();

            PC.SCUser user = NewObject <PC.SCUser>("测试用户");

            FacadeWithAcl.AddUser(user, null);

            var actual = GetSCUserByCodeName(user.CodeName);

            Assert.IsNotNull(actual);
        }
Esempio n. 4
0
        internal static IUser CastUser(PC.SCUser obj)
        {
            IUserPropertyAccessible user = new DemoUser();

            user.Name        = obj.Name;
            user.ObjectType  = SchemaType.Users;
            user.DisplayName = obj.DisplayName;
            user.Email       = obj.Properties.GetValue <string>("Mail", string.Empty);
            user.ID          = obj.ID;
            user.LogOnName   = obj.CodeName;
            user.Rank        = UserRankType.FuKeji;

            return((IUser)user);
        }
Esempio n. 5
0
        private static PC.SCUser FillAdditionProperties(PC.SCUser user)
        {
            user.Properties["Mail"].StringValue    = "*****@*****.**";
            user.Properties["Sip"].StringValue     = "*****@*****.**";
            user.Properties["MP"].StringValue      = "*****@*****.**";
            user.Properties["WP"].StringValue      = "*****@*****.**";
            user.Properties["Address"].StringValue = "*****@*****.**";

            //user.Properties["CadreType"].StringValue = ((int)UserAttributesType.ShuGuanGanBu).ToString(); //干部属性
            //user.Properties["UserRank"].StringValue = ((int)UserRankType.FuBuJi).ToString(); //人员职级
            //user.Properties["Occupation"].StringValue = "test any"; //职位

            return(user);
        }
Esempio n. 6
0
        private static PC.SchemaObjectBase MeargeChanges(System.DirectoryServices.SearchResult searchResult, PC.SchemaObjectBase schemaObjectBase)
        {
            PC.SCUser user = (PC.SCUser)schemaObjectBase;

            if (searchResult.Properties.Contains("msRTCSIP-PrimaryUserAddress"))
            {
                user.Properties.SetValue("Sip", searchResult.Properties["msRTCSIP-PrimaryUserAddress"][0].ToString());
            }

            if (searchResult.Properties.Contains("mail"))
            {
                user.Properties.SetValue("Mail", searchResult.Properties["mail"][0].ToString());
            }

            return(schemaObjectBase);
        }
Esempio n. 7
0
        private static void InitSecretaries()
        {
            // 秘书
            PC.SCUser wanglich = (PC.SCUser)PC.Adapters.SchemaObjectAdapter.Instance.LoadByCodeName("Users", "wanglch", SchemaObjectStatus.Normal, DateTime.MinValue);

            PC.SCUser liyem = (PC.SCUser)PC.Adapters.SchemaObjectAdapter.Instance.LoadByCodeName("Users", "liyem", SchemaObjectStatus.Normal, DateTime.MinValue);

            PC.SCUser yangrui1 = (PC.SCUser)PC.Adapters.SchemaObjectAdapter.Instance.LoadByCodeName("Users", "yangrui1", SchemaObjectStatus.Normal, DateTime.MinValue);

            PC.SCUser chenke = (PC.SCUser)PC.Adapters.SchemaObjectAdapter.Instance.LoadByCodeName("Users", "chenke", SchemaObjectStatus.Normal, DateTime.MinValue);

            PC.Executors.SCObjectOperations.Instance.AddSecretaryToUser(liyem, wanglich);

            PC.Executors.SCObjectOperations.Instance.AddSecretaryToUser(yangrui1, wanglich);

            PC.Executors.SCObjectOperations.Instance.AddSecretaryToUser(liyem, chenke);

            PC.Executors.SCObjectOperations.Instance.AddSecretaryToUser(wanglich, chenke);
        }
Esempio n. 8
0
        private static void InitUsers()
        {
            PC.SCOrganization org = (PC.SCOrganization)PC.Adapters.SchemaObjectAdapter.Instance.LoadByCodeName(c =>
            {
                SchemaStrict(c, "O.", PC.StandardObjectSchemaType.Organizations);
            }, DateTime.MinValue, "流程管理部").First();

            PC.SCUser user1 = FillAdditionProperties(new PC.SCUser()
            {
                Name        = "樊海云",
                DisplayName = "樊海云",
                CodeName    = "fanhy",
                FirstName   = "海云",
                LastName    = "樊",
                Status      = SchemaObjectStatus.Normal,
                ID          = "3210EEA0-9E13-44E3-A321-D7693BD0911F",
                Creator     = CastUser(Wangli),
            });

            PC.SCUser user2 = FillAdditionProperties(new PC.SCUser()
            {
                Name        = "杨睿1",
                DisplayName = "杨睿(集团流程管理部)",
                CodeName    = "yangrui1",
                FirstName   = "睿1",
                LastName    = "杨",
                Status      = SchemaObjectStatus.Normal,
                ID          = "766DFF51-6A29-43B2-95D9-D33456E536F9",
                Creator     = CastUser(Wangli),
            });

            user2.Properties["Mail"].StringValue = "*****@*****.**";

            PC.SCUser user3 = FillAdditionProperties(new PC.SCUser()
            {
                Name        = "刘闽辉",
                DisplayName = "刘闽辉",
                CodeName    = "liumh",
                FirstName   = "闽辉",
                LastName    = "刘",
                Status      = SchemaObjectStatus.Normal,
                ID          = "3729DAC3-80E0-476C-8C4A-264E0F67BBC2",
                Creator     = CastUser(Wangli),
            });

            user3.Properties["Mail"].StringValue = "*****@*****.**";

            Facade.AddUser(user1, org);
            Facade.AddUser(user2, org);
            Facade.AddUser(user3, org);

            PC.Adapters.UserPasswordAdapter.Instance.SetPassword(user3.ID, PC.Adapters.UserPasswordAdapter.GetPasswordType(), "password");

            PC.SCUser userOther = FillAdditionProperties(new PC.SCUser()
            {
                Name        = "王立臣",
                DisplayName = "王立臣",
                CodeName    = "wanglch",
                FirstName   = "立臣",
                LastName    = "王",
                Status      = SchemaObjectStatus.Normal,
                ID          = "587200E1-3EC4-43B2-8F3A-167E20F41D09",
                Creator     = CastUser(Wangli),
            });

            userOther.Properties["Mail"].StringValue = "*****@*****.**";


            PC.SCOrganization orgOther = (PC.SCOrganization)PC.Adapters.SchemaObjectAdapter.Instance.LoadByCodeName(c =>
            {
                SchemaStrict(c, "O.", PC.StandardObjectSchemaType.Organizations);
            }, DateTime.MinValue, "costEngineer").First();

            Facade.AddUser(userOther, orgOther);

            orgOther = (PC.SCOrganization)PC.Adapters.SchemaObjectAdapter.Instance.LoadByCodeName(c =>
            {
                SchemaStrict(c, "O.", PC.StandardObjectSchemaType.Organizations);
            }, DateTime.MinValue, "beijingYuanlianExecutives").First();

            Facade.AddUserToOrganization(user3, orgOther);

            orgOther = (PC.SCOrganization)PC.Adapters.SchemaObjectAdapter.Instance.LoadByCodeName(c =>
            {
                SchemaStrict(c, "O.", PC.StandardObjectSchemaType.Organizations);
            }, DateTime.MinValue, "养老地产业务发展中心").First();

            userOther = FillAdditionProperties(new PC.SCUser()
            {
                Name        = "赵林",
                DisplayName = "赵林",
                CodeName    = "zhaolin1",
                FirstName   = "林",
                LastName    = "赵",
                Status      = SchemaObjectStatus.Normal,
                ID          = "D1C28431-DD5D-496E-865B-85C6D89ED3D6",
                Creator     = CastUser(Wangli),
            });

            userOther.Properties["Mail"].StringValue = "*****@*****.**";

            Facade.AddUser(userOther, orgOther);

            userOther = FillAdditionProperties(new PC.SCUser()
            {
                Name        = "李业明",
                DisplayName = "李业明",
                CodeName    = "liyem",
                FirstName   = "业明",
                LastName    = "李",
                Status      = SchemaObjectStatus.Normal,
                ID          = "B36CC307-1D92-4D27-B670-A4301006BF0B",
                Creator     = CastUser(Wangli),
            });

            userOther.Properties["Mail"].StringValue = "*****@*****.**";

            Facade.AddUser(userOther, orgOther);

            userOther = FillAdditionProperties(new PC.SCUser()
            {
                Name        = "张帅一",
                DisplayName = "张帅一",
                CodeName    = "zhangshuaiy",
                FirstName   = "帅一",
                LastName    = "张",
                Status      = SchemaObjectStatus.Normal,
                ID          = "EF68CDD1-3FD3-418A-8D4D-98F2E02FB2CA",
                Creator     = CastUser(Wangli),
            });

            userOther.Properties["Mail"].StringValue = "*****@*****.**";

            Facade.AddUser(userOther, org);                    //主职

            Facade.AddUserToOrganization(userOther, orgOther); //兼职

            Facade.SetUserDefaultOrganization(userOther, org); //确保主职


            userOther = FillAdditionProperties(new PC.SCUser()
            {
                Name        = "陈科",
                DisplayName = "陈科",
                CodeName    = "chenke",
                FirstName   = "科",
                LastName    = "陈",
                Status      = SchemaObjectStatus.Normal,
                ID          = "E8F71526-23A2-4A39-A8AC-F79A2D255D1A",
                Creator     = CastUser(Wangli),
            });

            userOther.Properties["Mail"].StringValue = "*****@*****.**";

            orgOther = (PC.SCOrganization)PC.Adapters.SchemaObjectAdapter.Instance.LoadByCodeName(c =>
            {
                SchemaStrict(c, "O.", PC.StandardObjectSchemaType.Organizations);
            }, DateTime.MinValue, "costEngineer").First();

            Facade.AddUser(userOther, orgOther);

            // 独立部门开始

            userOther = FillAdditionProperties(new PC.SCUser()
            {
                Name        = "王发平",
                DisplayName = "王发平",
                CodeName    = "wangfaping",
                FirstName   = "发平",
                LastName    = "王",
                Status      = SchemaObjectStatus.Normal,
                ID          = "2B67F7D0-9362-401F-977F-3E267E87298B",
                Creator     = CastUser(Wangli),
            });

            userOther.Properties["Mail"].StringValue = "*****@*****.**";

            orgOther = (PC.SCOrganization)PC.Adapters.SchemaObjectAdapter.Instance.LoadByCodeName(c =>
            {
                SchemaStrict(c, "O.", PC.StandardObjectSchemaType.Organizations);
            }, DateTime.MinValue, "yuanyangAobei").First();

            Facade.AddUser(userOther, orgOther);

            userOther = FillAdditionProperties(new PC.SCUser()
            {
                Name        = "金戈",
                DisplayName = "金戈",
                CodeName    = "jinge",
                FirstName   = "戈",
                LastName    = "金",
                Status      = SchemaObjectStatus.Normal,
                ID          = "1688EB81-0FFB-4072-B26B-6DB571DCC391",
                Creator     = CastUser(Wangli),
            });

            userOther.Properties["Mail"].StringValue = "*****@*****.**";

            Facade.AddUser(userOther, orgOther);

            userOther = FillAdditionProperties(new PC.SCUser()
            {
                Name        = "范晓君",
                DisplayName = "范晓君",
                CodeName    = "fanxiaojun",
                FirstName   = "晓君",
                LastName    = "范",
                Status      = SchemaObjectStatus.Normal,
                ID          = "165EE11A-76ED-4C91-BD02-4AB6703F8FFA",
                Creator     = CastUser(Wangli),
            });

            userOther.Properties["Mail"].StringValue = "*****@*****.**";

            orgOther = (PC.SCOrganization)PC.Adapters.SchemaObjectAdapter.Instance.LoadByCodeName(c =>
            {
                SchemaStrict(c, "O.", PC.StandardObjectSchemaType.Organizations);
            }, DateTime.MinValue, "beijingSOIC").First();

            Facade.AddUser(userOther, orgOther);

            userOther = FillAdditionProperties(new PC.SCUser()
            {
                Name        = "高根",
                DisplayName = "高根",
                CodeName    = "gaogen",
                FirstName   = "根",
                LastName    = "高",
                Status      = SchemaObjectStatus.Normal,
                ID          = "81987195-756E-4FDA-868E-E4177096B212",
                Creator     = CastUser(Wangli),
            });

            userOther.Properties["Mail"].StringValue = "*****@*****.**";

            Facade.AddUser(userOther, orgOther);

            userOther = FillAdditionProperties(new PC.SCUser()
            {
                Name        = "胡瑞雪",
                DisplayName = "胡瑞雪",
                CodeName    = "hurx",
                FirstName   = "瑞雪",
                LastName    = "胡",
                Status      = SchemaObjectStatus.Normal,
                ID          = "4FD109E4-FFC5-487C-B99B-DB20B6A0B2B9",
                Creator     = CastUser(Wangli),
            });

            userOther.Properties["Mail"].StringValue = "*****@*****.**";

            orgOther = (PC.SCOrganization)PC.Adapters.SchemaObjectAdapter.Instance.LoadByCodeName(c =>
            {
                SchemaStrict(c, "O.", PC.StandardObjectSchemaType.Organizations);
            }, DateTime.MinValue, "beijingSOI").First();

            Facade.AddUser(userOther, orgOther);
        }
Esempio n. 9
0
 protected void SetCurrentPrincipal(PC.SCUser user)
 {
     this.Principal = new DeluxePrincipal(new DeluxeIdentity(OguObjectGenerator1.CastUser(user)));
 }