Beispiel #1
0
        private static void ApplyChanges(List <SimpleUser> changes, ADToPermissionCenterSynchronizer context)
        {
            string[] changesIdArray             = changes.Select <SimpleUser, string>(m => m.SCObjectID).ToArray();
            PC.SchemaObjectCollection pcObjects = LoadSCObjects(changesIdArray);

            foreach (SimpleUser item in changes)
            {
                if (pcObjects.ContainsKey(item.SCObjectID))
                {
                    try
                    {
                        PC.SchemaObjectBase scObj = MeargeChanges(item.Tag, pcObjects[item.SCObjectID]);

                        PC.Adapters.SchemaObjectAdapter.Instance.Update(scObj);
                        context.Log.NumberOfModifiedItems++;
                    }
                    catch (Exception ex)
                    {
                        context.Log.NumberOfExceptions++;
                        context.Log.Status = ADSynchronizeResult.HasError;
                        LogHelper.WriteReverseSynchronizeDBLogDetail(context.Log.LogID, item.SCObjectID, AttributeHelper.Hex((byte[])item.Tag.Properties["objectguid"][0]), item.CodeName, ex.Message, ex.ToString());
                        Trace.TraceError("未成功更新," + ex.ToString());
                    }
                }
                else
                {
                    LogHelper.WriteReverseSynchronizeDBLogDetail(context.Log.LogID, item.SCObjectID, AttributeHelper.Hex((byte[])item.Tag.Properties["objectguid"][0]), item.CodeName, "未找到AD对象对应的权限中心对象。", null);
                }
            }
        }
Beispiel #2
0
		private OP.IRole CastRole(PC.SchemaObjectBase obj, OP.IApplication app)
		{
			OP.RoleImpl role = Util.GetPermissionObjectFactory().CreateObject(typeof(OP.IRole)) as OP.RoleImpl;
			var wrapper = role as OP.IApplicationMemberPropertyAccessible;

			if (wrapper == null)
				throw new InvalidCastException("工厂创建的对象应实现IApplicationMemberPropertyAccessible,否则无法适用此工厂。");

			wrapper.CodeName = obj.Properties.GetValue<string>("CodeName", string.Empty);
			wrapper.Description = obj.Properties.GetValue<string>("Description", string.Empty);
			wrapper.ID = obj.ID;
			wrapper.Name = obj.Properties.GetValue<string>("Name", string.Empty);
			wrapper.Application = app;

			return role;
		}
Beispiel #3
0
		private OP.IPermission CastPermission(PC.SchemaObjectBase obj, OP.IApplication app)
		{
			OP.IPermission per = (OP.IPermission)Util.GetPermissionObjectFactory().CreateObject(typeof(OP.IPermission));
			if (per is OP.IApplicationMemberPropertyAccessible)
			{
				OP.IApplicationMemberPropertyAccessible wrapper = (OP.IApplicationMemberPropertyAccessible)per;
				wrapper.CodeName = obj.Properties.GetValue<string>("CodeName", string.Empty);
				wrapper.Description = obj.Properties.GetValue<string>("Description", string.Empty);
				wrapper.ID = obj.ID;
				wrapper.Name = obj.Properties.GetValue<string>("Name", string.Empty);
				wrapper.Application = app;
			}
			else
			{
				throw new InvalidCastException("工厂创建的对象应实现IPermissionPropertyAccessible");
			}

			return per;
		}
Beispiel #4
0
		private OP.IApplication CastApplication(PC.SchemaObjectBase o)
		{
			if (o == null)
				throw new ArgumentNullException("o");

			if (o.SchemaType != PC.StandardObjectSchemaType.Applications.ToString())
				throw new ArgumentException(string.Format("无法将{0}转换成IApplication", o), "o");

			OP.ApplicationImpl app = new OP.ApplicationImpl();

			var wrapper = (OP.IApplicationPropertyAccessible)app;

			wrapper.CodeName = o.Properties.GetValue<string>("CodeName", string.Empty);
			wrapper.Description = o.Properties.GetValue<string>("Description", string.Empty);
			wrapper.ID = o.ID;
			wrapper.Name = o.Properties.GetValue<string>("Name", string.Empty);
			wrapper.ResourceLevel = o.Properties.GetValue<string>("ResourceLevel", string.Empty);
			return app;
		}
Beispiel #5
0
        protected void SetContainerMemberAndPermissions(PC.SchemaObjectBase container, PC.SCRole member, string[] permissions)
        {
            PC.Permissions.SCAclContainer cc = new PC.Permissions.SCAclContainer(container);
            if (permissions != null)
            {
                foreach (string permission in permissions)
                {
                    cc.Members.AddNotExistsItem(new PC.Permissions.SCAclItem(permission, member));
                }
            }

            var old = PC.Adapters.SCAclAdapter.Instance.LoadByContainerID(container.ID, DateTime.MinValue);

            if (old != null)
            {
                cc.Members.MergeChangedItems(old);
            }

            PC.Adapters.SCAclAdapter.Instance.Update(cc);
        }
Beispiel #6
0
        internal void CalculateFullPathAndGlobalSort(SchemaObjectBase parent, SchemaObjectBase child)
        {
            this.InnerSort = ((ISCRelationContainer)parent).GetCurrentMaxInnerSort() + 1;

            string parentGlobalSort = "000000";
            string parentFullPath   = ((ISCQualifiedNameObject)parent).GetQualifiedName();

            if (parent.ID == SCOrganization.GetRoot().ID)
            {
                parentGlobalSort = string.Empty;
                parentFullPath   = string.Empty;
            }
            else
            {
                if (parent.CurrentParentRelations.Count > 0)
                {
                    if (parent.CurrentParentRelations[0].FullPath.IsNotEmpty())
                    {
                        parentFullPath = parent.CurrentParentRelations[0].FullPath;
                    }

                    if (parent.CurrentParentRelations[0].GlobalSort.IsNotEmpty())
                    {
                        parentGlobalSort = parent.CurrentParentRelations[0].GlobalSort;
                    }
                }
            }

            string childName = ((ISCQualifiedNameObject)child).GetQualifiedName();

            if (parentFullPath.IsNotEmpty())
            {
                this.FullPath = parentFullPath + "\\" + childName;
            }
            else
            {
                this.FullPath = childName;
            }

            this.GlobalSort = parentGlobalSort + string.Format("{0:000000}", this.InnerSort);
        }
Beispiel #7
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);
        }
Beispiel #8
0
 /// <summary>
 /// 使用指定的容器对象和成员对象 初始化<see cref="SCMemberRelation"/>的新实例
 /// </summary>
 /// <param name="container">容器对象</param>
 /// <param name="member">成员对象</param>
 public SCMemberRelation(SchemaObjectBase container, SchemaObjectBase member) :
     base(container, member, StandardObjectSchemaType.MemberRelations.ToString())
 {
 }
 protected override void DoExecuteItem(MCS.Library.SOA.DataObjects.Security.SchemaObjectBase src, MCS.Library.SOA.DataObjects.Security.SchemaObjectBase target)
 {
     this.ReportProgress(string.Format("正在添加向组织 {0} 添加人员 {1}", ((SCBase)target).DisplayName, ((SCBase)src).DisplayName), true);
     SCObjectOperations.InstanceWithPermissions.AddUserToOrganization((SCUser)src, (SCOrganization)target);
 }
 protected override void DoExecuteItem(MCS.Library.SOA.DataObjects.Security.SchemaObjectBase src, MCS.Library.SOA.DataObjects.Security.SchemaObjectBase target)
 {
     this.ReportProgress(string.Format("正在移动{0}", ((SCBase)src).DisplayName), true);
     SCObjectOperations.InstanceWithPermissions.MoveObjectToOrganization(this.ParentOrg, (SCBase)src, (SCOrganization)target);
 }
        public static PropertyEditorSceneAdapter Create(MCS.Library.SOA.DataObjects.Security.SchemaObjectBase schemaObj)
        {
            var category = ObjectSchemaSettings.GetConfig().Schemas[schemaObj.SchemaType].Category;

            return(PropertyEditorSceneAdapter.CreateByCategory(category));
        }