protected override void SetPropertyValue(IOguObject srcOguObject, string srcPropertyName, DirectoryEntry entry, string targetPropertyName, string context, SetterContext setterContext)
		{
			entry.InvokeSet(targetPropertyName,
				new object[] { SynchronizeHelper.GetADAccountExpiresDate(srcOguObject.Properties[srcPropertyName]) });

			TraceItHere(srcOguObject.ObjectType.ToString(), srcPropertyName, entry.Name, targetPropertyName, context, srcOguObject.Properties[srcPropertyName].ToString(), SynchronizeHelper.GetADAccountExpiresDate(srcOguObject.Properties[srcPropertyName]).ToLongTimeString());
		}
		protected override void SetPropertyValue(IOguObject srcOguObject, string srcPropertyName, DirectoryEntry entry, string targetPropertyName, string context, SetterContext setterContext)
		{
			string srcPropertyValue = GetNormalizeddSourceValue(srcOguObject, srcPropertyName, context);
			string targetPropertyValue = GetNormalizeddTargetValue(entry, targetPropertyName, context);

			if (srcPropertyValue != targetPropertyValue)
			{
				//entry.CommitChanges();
				try
				{
					entry.Properties[targetPropertyName].Value = srcOguObject.Properties[srcPropertyName];
					// entry.CommitChanges();
				}
				catch (DirectoryServicesCOMException ex)
				{
					if (ex.ErrorCode == -2147019886)
					{
						//对象已存在
						entry.Properties[targetPropertyName].Value = "TMP" + Environment.TickCount.ToString("X");
						entry.CommitChanges();
						SynchronizeContext.Current.DelayActions.Add(new DelayRenameCodeNameAction(srcOguObject, srcPropertyName, entry.NativeGuid, targetPropertyName));
					}
					else
					{
						throw;
					}
				}
			}
		}
		public override void AfterObjectUpdated(IOguObject srcOguObject, string srcPropertyName, System.DirectoryServices.DirectoryEntry entry, string targetPropertyName, string context, SetterContext setterContext)
		{
			if (DictionaryHelper.GetValue<string, object, bool>(setterContext, "StringCollectionPropertySetter_LazySetProperties", false))
			{
				RefillCollection((string)srcOguObject.Properties[srcPropertyName], entry.Properties[targetPropertyName]);

				setterContext.PropertyChanged = true;
			}
		}
		public override void AfterObjectUpdated(IOguObject srcOguObject, string srcPropertyName, DirectoryEntry entry, string targetPropertyName, string context, SetterContext setterContext)
		{
			if (DictionaryHelper.GetValue<string, object, bool>(setterContext, "UACPropertySetter_LazySetProperties", false))
			{
				MergeUACValue(srcOguObject, srcPropertyName, entry, targetPropertyName, context);

				setterContext.PropertyChanged = true;
			}
		}
Beispiel #5
0
        public override void Convert(ObjectModifyType modifyType, IOguObject srcObject, DirectoryEntry targetObject, string context)
        {
            SetterContext setterContext = new SetterContext();

            ConvertProperties(srcObject, targetObject, setterContext);

            targetObject.CommitChanges();

            DoAfterObjectUpdatedOP(srcObject, targetObject, setterContext);
        }
		public override void Convert(ObjectModifyType modifyType, IOguObject srcObject, DirectoryEntry targetObject, string context)
		{
			SetterContext setterContext = new SetterContext();

			ConvertProperties(srcObject, targetObject, setterContext);

			targetObject.CommitChanges();

			DoAfterObjectUpdatedOP(srcObject, targetObject, setterContext);
		}
		public override void AfterObjectUpdated(object srcObject, string srcPropertyName, object targetObject, string targetPropertyName, string context, SetterContext setterContext)
		{
			(srcObject is IOguObject).FalseThrow("srcObject必须是IOguObject类型");
			(targetObject is DirectoryEntry).FalseThrow("targetObject必须是DirectoryEntry类型");

			IOguObject srcOguObject = (IOguObject)srcObject;
			DirectoryEntry entry = (DirectoryEntry)targetObject;

			AfterObjectUpdated(srcOguObject, srcPropertyName, entry, targetPropertyName, context, setterContext);
		}
		public override void Convert(ObjectModifyType modifyType, IOguObject srcObject, DirectoryEntry targetObject, string context)
		{
			SetterContext setterContext = new SetterContext();

			ConvertProperties(srcObject, targetObject, setterContext);

			targetObject.CommitChanges();

			if (SynchronizeContext.Current.DefaultPassword.IsNotEmpty())
				targetObject.Invoke("SetPassword", SynchronizeContext.Current.DefaultPassword);

			DoAfterObjectUpdatedOP(srcObject, targetObject, setterContext);
		}
Beispiel #9
0
        public override void Convert(DataObjects.Security.Transfer.ObjectModifyType modifyType, OGUPermission.IOguObject srcObject, System.DirectoryServices.DirectoryEntry targetObject, string context)
        {
            IGroup        grp           = (IGroup)srcObject;
            SetterContext setterContext = new SetterContext();

            ConvertProperties(srcObject, targetObject, setterContext);

            targetObject.Properties["displayNamePrintable"].Value = SynchronizeHelper.PermissionCenterInvolved;

            targetObject.CommitChanges();

            DoAfterObjectUpdatedOP(srcObject, targetObject, setterContext);
        }
		public override void Convert(DataObjects.Security.Transfer.ObjectModifyType modifyType, OGUPermission.IOguObject srcObject, System.DirectoryServices.DirectoryEntry targetObject, string context)
		{
			IGroup grp = (IGroup)srcObject;
			SetterContext setterContext = new SetterContext();

			ConvertProperties(srcObject, targetObject, setterContext);

			targetObject.Properties["displayNamePrintable"].Value = SynchronizeHelper.PermissionCenterInvolved;

			targetObject.CommitChanges();

			DoAfterObjectUpdatedOP(srcObject, targetObject, setterContext);
		}
		protected override void SetPropertyValue(IOguObject srcOguObject, string srcPropertyName, DirectoryEntry entry, string targetPropertyName, string context, SetterContext setterContext)
		{
			string srcPropertyValue = GetNormalizeddSourceValue(srcOguObject, srcPropertyName, context);
			string targetPropertyValue = GetNormalizeddTargetValue(entry, targetPropertyName, context);

			if (srcPropertyValue != targetPropertyValue)
			{
				TraceItHere(srcOguObject.ObjectType.ToString(), srcPropertyName, entry.Name, targetPropertyName, context, srcPropertyValue, targetPropertyValue);
				entry.Properties[targetPropertyName].Value = srcPropertyValue;

				TracePropertyValue(entry, targetPropertyName);
			}
		}
		public override void Convert(ObjectModifyType modifyType, IOguObject srcObject, DirectoryEntry targetObject, string context)
		{
			SetterContext setterContext = new SetterContext();

			ConvertProperties(srcObject, targetObject, setterContext);

			targetObject.CommitChanges();

			if (!ObjectComparerHelper.AreParentPathEqaul(srcObject, targetObject))
				MoveItemToNewPath(srcObject, targetObject);

			DoAfterObjectUpdatedOP(srcObject, targetObject, setterContext);
		}
        public override void Convert(ObjectModifyType modifyType, IOguObject srcObject, DirectoryEntry targetObject, string context)
        {
            SetterContext setterContext = new SetterContext();

            ConvertProperties(srcObject, targetObject, setterContext);

            targetObject.CommitChanges();

            if (SynchronizeContext.Current.DefaultPassword.IsNotEmpty())
            {
                targetObject.Invoke("SetPassword", SynchronizeContext.Current.DefaultPassword);
            }

            DoAfterObjectUpdatedOP(srcObject, targetObject, setterContext);
        }
        public override void Convert(ObjectModifyType modifyType, IOguObject srcObject, DirectoryEntry targetObject, string context)
        {
            SetterContext setterContext = new SetterContext();

            ConvertProperties(srcObject, targetObject, setterContext);

            targetObject.CommitChanges();

            if (!ObjectComparerHelper.AreParentPathEqaul(srcObject, targetObject))
            {
                MoveItemToNewPath(srcObject, targetObject);
            }

            DoAfterObjectUpdatedOP(srcObject, targetObject, setterContext);
        }
		protected override void SetPropertyValue(IOguObject srcOguObject, string srcPropertyName, System.DirectoryServices.DirectoryEntry entry, string targetPropertyName, string context, SetterContext setterContext)
		{
			string srcValue = (string)srcOguObject.Properties[srcPropertyName];
			var targetValues = entry.Properties[targetPropertyName];

			if (entry.IsBounded())
			{
				RefillCollection(srcValue, targetValues);
			}
			else
			{
				// 无中生有,此时检查有无修改,如果有修改,则应延迟操作。
				if (string.IsNullOrEmpty(srcValue) == false)
				{
					setterContext["StringCollectionPropertySetter_LazySetProperties"] = true;
				}
			}
		}
		protected override void SetPropertyValue(IOguObject srcOguObject, string srcPropertyName, DirectoryEntry entry, string targetPropertyName, string context, SetterContext setterContext)
		{
			int userAccountControl = Convert.ToInt32(entry.Properties[targetPropertyName].Value); // 可能为null

			int result = userAccountControl;

			if (userAccountControl == 0 || entry.IsBounded() == false)
			{
				result = (int)(ADS_USER_FLAG.ADS_UF_NORMAL_ACCOUNT | ADS_USER_FLAG.ADS_UF_PASSWD_NOTREQD);
				entry.Properties[targetPropertyName].Value = result;

				setterContext["UACPropertySetter_LazySetProperties"] = true;
			}
			else
			{
				MergeUACValue(srcOguObject, srcPropertyName, entry, targetPropertyName, context);
			}
		}
		protected override void SetPropertyValue(IOguObject srcOguObject, string srcPropertyName, DirectoryEntry entry, string targetPropertyName, string context, SetterContext setterContext)
		{
			string srcPropertyValue = GetNormalizeddSourceValue(srcOguObject, srcPropertyName, context);
			string targetPropertyValue = GetNormalizeddTargetValue(entry, targetPropertyName, context);

			if (srcOguObject.FullPath == SynchronizeContext.Current.SourceRootPath)
			{
				srcPropertyValue = new PathPartEnumerator(SynchronizeContext.Current.TargetRootOU).Last(); //极其特别,不一定可靠,权限中心应限制更改这一组织的名称和位置。
			}
			else
			{
				string relativePath = SynchronizeHelper.GetRelativePath(srcOguObject);
				if (relativePath.IndexOf('\\') < 0)
				{
					srcPropertyValue = SynchronizeContext.Current.GetMappedName(srcPropertyValue);
				}
			}

			if (srcPropertyValue != targetPropertyValue && entry.IsBounded() == true)
			{
				TraceItHere(srcOguObject, srcPropertyName, entry, targetPropertyName, context, srcPropertyValue, targetPropertyValue);
				entry.CommitChanges();
				try
				{
					entry.Rename(srcOguObject.ObjectType.SchemaTypeToPrefix() + "=" + ADHelper.EscapeString(srcPropertyValue));
				}
				catch (DirectoryServicesCOMException ex)
				{
					if (ex.ErrorCode == -2147019886)
					{
						//对象已存在
						entry.Rename(srcOguObject.ObjectType.SchemaTypeToPrefix() + "=TMP" + Environment.TickCount.ToString("X"));
						SynchronizeContext.Current.DelayActions.Add(new DelayRenameAction(srcOguObject, entry.NativeGuid));
					}
					else
					{
						throw;
					}
				}
			}
		}
        protected override void SetPropertyValue(IOguObject srcOguObject, string srcPropertyName, DirectoryEntry entry, string targetPropertyName, string context, SetterContext setterContext)
        {
            string srcPropertyValue    = GetNormalizeddSourceValue(srcOguObject, srcPropertyName, context);
            string targetPropertyValue = GetNormalizeddTargetValue(entry, targetPropertyName, context);

            if (srcOguObject.FullPath == SynchronizeContext.Current.SourceRootPath)
            {
                srcPropertyValue = new PathPartEnumerator(SynchronizeContext.Current.TargetRootOU).Last();                 //极其特别,不一定可靠,权限中心应限制更改这一组织的名称和位置。
            }
            else
            {
                string relativePath = SynchronizeHelper.GetRelativePath(srcOguObject);
                if (relativePath.IndexOf('\\') < 0)
                {
                    srcPropertyValue = SynchronizeContext.Current.GetMappedName(srcPropertyValue);
                }
            }

            if (srcPropertyValue != targetPropertyValue && entry.IsBounded() == true)
            {
                TraceItHere(srcOguObject, srcPropertyName, entry, targetPropertyName, context, srcPropertyValue, targetPropertyValue);
                entry.CommitChanges();
                try
                {
                    entry.Rename(srcOguObject.ObjectType.SchemaTypeToPrefix() + "=" + ADHelper.EscapeString(srcPropertyValue));
                }
                catch (DirectoryServicesCOMException ex)
                {
                    if (ex.ErrorCode == -2147019886)
                    {
                        //对象已存在
                        entry.Rename(srcOguObject.ObjectType.SchemaTypeToPrefix() + "=TMP" + Environment.TickCount.ToString("X"));
                        SynchronizeContext.Current.DelayActions.Add(new DelayRenameAction(srcOguObject, entry.NativeGuid));
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }
        protected override void SetPropertyValue(IOguObject srcOguObject, string srcPropertyName, DirectoryEntry entry, string targetPropertyName, string context, SetterContext setterContext)
        {
            int userAccountControl = Convert.ToInt32(entry.Properties[targetPropertyName].Value);             // 可能为null

            int result = userAccountControl;

            if (userAccountControl == 0 || entry.IsBounded() == false)
            {
                result = (int)(ADS_USER_FLAG.ADS_UF_NORMAL_ACCOUNT | ADS_USER_FLAG.ADS_UF_PASSWD_NOTREQD);
                entry.Properties[targetPropertyName].Value = result;

                setterContext["UACPropertySetter_LazySetProperties"] = true;
            }
            else
            {
                MergeUACValue(srcOguObject, srcPropertyName, entry, targetPropertyName, context);
            }
        }
Beispiel #20
0
        protected static void ConvertProperties(IOguObject srcObject, DirectoryEntry entry, SetterContext setterContext, bool delayed)
        {
            SchemaMappingInfo mappingInfo = PermissionCenterToADSynchronizeSettings.GetConfig().SchemaMappings.GetSchemaMappingInfo(srcObject.ObjectType.ToString());

            foreach (SetterPropertyMappingConfigurationElement element in mappingInfo.ModifiedProperties)
            {
                if (element.Delay == delayed)
                {
                    element.Setter.SetValue(srcObject, element.Name, entry, element.TargetPropertyName, element.Context, setterContext);
                }
            }
        }
		/// <summary>
		/// 当对象的属性值全部设置完后,且已经提交后的后续处理
		/// </summary>
		/// <param name="srcObject"></param>
		/// <param name="srcPropertyName"></param>
		/// <param name="targetObject"></param>
		/// <param name="targetPropertyName"></param>
		/// <param name="context"></param>
		/// <param name="setterContext"></param>
		public abstract void AfterObjectUpdated(object srcObject, string srcPropertyName, object targetObject, string targetPropertyName, string context, SetterContext setterContext);
        public override void AfterObjectUpdated(IOguObject srcOguObject, string srcPropertyName, DirectoryEntry entry, string targetPropertyName, string context, SetterContext setterContext)
        {
            if (DictionaryHelper.GetValue <string, object, bool>(setterContext, "UACPropertySetter_LazySetProperties", false))
            {
                MergeUACValue(srcOguObject, srcPropertyName, entry, targetPropertyName, context);

                setterContext.PropertyChanged = true;
            }
        }
        public override void AfterObjectUpdated(object srcObject, string srcPropertyName, object targetObject, string targetPropertyName, string context, SetterContext setterContext)
        {
            (srcObject is IOguObject).FalseThrow("srcObject必须是IOguObject类型");
            (targetObject is DirectoryEntry).FalseThrow("targetObject必须是DirectoryEntry类型");

            IOguObject     srcOguObject = (IOguObject)srcObject;
            DirectoryEntry entry        = (DirectoryEntry)targetObject;

            AfterObjectUpdated(srcOguObject, srcPropertyName, entry, targetPropertyName, context, setterContext);
        }
        protected override void SetPropertyValue(IOguObject srcOguObject, string srcPropertyName, System.DirectoryServices.DirectoryEntry entry, string targetPropertyName, string context, SetterContext setterContext)
        {
            string srcValue     = (string)srcOguObject.Properties[srcPropertyName];
            var    targetValues = entry.Properties[targetPropertyName];

            if (entry.IsBounded())
            {
                RefillCollection(srcValue, targetValues);
            }
            else
            {
                // 无中生有,此时检查有无修改,如果有修改,则应延迟操作。
                if (string.IsNullOrEmpty(srcValue) == false)
                {
                    setterContext["StringCollectionPropertySetter_LazySetProperties"] = true;
                }
            }
        }
Beispiel #25
0
 private HttpServerSetter(IHttpServer server)
 {
     _server = server;
     _props = new SetterContext();
 }
        protected override void SetPropertyValue(IOguObject srcOguObject, string srcPropertyName, DirectoryEntry entry, string targetPropertyName, string context, SetterContext setterContext)
        {
            string srcPropertyValue    = GetNormalizeddSourceValue(srcOguObject, srcPropertyName, context);
            string targetPropertyValue = GetNormalizeddTargetValue(entry, targetPropertyName, context);

            if (srcPropertyValue != targetPropertyValue)
            {
                TraceItHere(srcOguObject.ObjectType.ToString(), srcPropertyName, entry.Name, targetPropertyName, context, srcPropertyValue, targetPropertyValue);
                entry.Properties[targetPropertyName].Value = srcPropertyValue;

                TracePropertyValue(entry, targetPropertyName);
            }
        }
        protected override void SetPropertyValue(IOguObject srcOguObject, string srcPropertyName, DirectoryEntry entry, string targetPropertyName, string context, SetterContext setterContext)
        {
            string srcPropertyValue    = GetNormalizeddSourceValue(srcOguObject, srcPropertyName, context);
            string targetPropertyValue = GetNormalizeddTargetValue(entry, targetPropertyName, context);

            if (srcPropertyValue != targetPropertyValue)
            {
                //entry.CommitChanges();
                try
                {
                    string targetValue = srcOguObject.Properties[srcPropertyName].ToString();
                    entry.Properties[targetPropertyName].Value  = targetValue;
                    entry.Properties["userPrincipalName"].Value = targetValue + (string.IsNullOrEmpty(targetValue) ? string.Empty : context);
                    // entry.CommitChanges();
                }
                catch (DirectoryServicesCOMException ex)
                {
                    if (ex.ErrorCode == -2147019886)
                    {
                        //对象已存在
                        entry.Properties[targetPropertyName].Value = "TMP" + Environment.TickCount.ToString("X");
                        entry.CommitChanges();
                        SynchronizeContext.Current.DelayActions.Add(new DelayRenameCodeNameAction(srcOguObject, srcPropertyName, entry.NativeGuid, targetPropertyName));
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }
        public override void AfterObjectUpdated(IOguObject srcOguObject, string srcPropertyName, System.DirectoryServices.DirectoryEntry entry, string targetPropertyName, string context, SetterContext setterContext)
        {
            if (DictionaryHelper.GetValue <string, object, bool>(setterContext, "StringCollectionPropertySetter_LazySetProperties", false))
            {
                RefillCollection((string)srcOguObject.Properties[srcPropertyName], entry.Properties[targetPropertyName]);

                setterContext.PropertyChanged = true;
            }
        }
Beispiel #29
0
        protected static void DoAfterObjectUpdatedOP(IOguObject srcObject, DirectoryEntry entry, SetterContext setterContext)
        {
            SchemaMappingInfo mappingInfo = PermissionCenterToADSynchronizeSettings.GetConfig().SchemaMappings.GetSchemaMappingInfo(srcObject.ObjectType.ToString());

            foreach (SetterPropertyMappingConfigurationElement element in mappingInfo.ModifiedProperties)
            {
                element.Setter.AfterObjectUpdated(srcObject, element.Name, entry, element.TargetPropertyName, element.Context, setterContext);
            }

            if (setterContext.PropertyChanged)
            {
                entry.CommitChanges();
            }
        }
 public virtual void AfterObjectUpdated(IOguObject srcOguObject, string srcPropertyName, DirectoryEntry entry, string targetPropertyName, string context, SetterContext setterContext)
 {
 }
		protected abstract void SetPropertyValue(IOguObject srcOguObject, string srcPropertyName, DirectoryEntry entry, string targetPropertyName, string context, SetterContext setterContext);
 protected abstract void SetPropertyValue(IOguObject srcOguObject, string srcPropertyName, DirectoryEntry entry, string targetPropertyName, string context, SetterContext setterContext);
		public virtual void AfterObjectUpdated(IOguObject srcOguObject, string srcPropertyName, DirectoryEntry entry, string targetPropertyName, string context, SetterContext setterContext)
		{
		}
Beispiel #34
0
        protected override void SetPropertyValue(IOguObject srcOguObject, string srcPropertyName, DirectoryEntry entry, string targetPropertyName, string context, SetterContext setterContext)
        {
            entry.InvokeSet(targetPropertyName,
                            new object[] { SynchronizeHelper.GetADAccountExpiresDate(srcOguObject.Properties[srcPropertyName]) });

            TraceItHere(srcOguObject.ObjectType.ToString(), srcPropertyName, entry.Name, targetPropertyName, context, srcOguObject.Properties[srcPropertyName].ToString(), SynchronizeHelper.GetADAccountExpiresDate(srcOguObject.Properties[srcPropertyName]).ToLongTimeString());
        }
		/// <summary>
		/// 设置属性的值
		/// </summary>
		/// <param name="srcObject"></param>
		/// <param name="srcPropertyName"></param>
		/// <param name="targetObject"></param>
		/// <param name="targetObjectName"></param>
		/// <param name="targetPropertyName"></param>
		/// <param name="context"></param>
		/// <param name="setterContext"></param>
		public abstract void SetValue(object srcObject, string srcPropertyName, object targetObject, string targetPropertyName, string context, SetterContext setterContext);