コード例 #1
0
        protected static void ConvertProperties(IOguObject srcObject, DirectoryEntry entry, SetterContext setterContext)
        {
            SchemaMappingInfo mappingInfo = PermissionCenterToADSynchronizeSettings.GetConfig().SchemaMappings.GetSchemaMappingInfo(srcObject.ObjectType.ToString());

            foreach (SetterPropertyMappingConfigurationElement element in mappingInfo.ModifiedProperties)
            {
                element.Setter.SetValue(srcObject, element.Name, entry, element.TargetPropertyName, element.Context, setterContext);
            }
        }
コード例 #2
0
        private static ADHelper CreateADHelper()
        {
            //初始化域控制器的配置信息
            ServerInfoConfigureElement serverSetting = ServerInfoConfigSettings.GetConfig().ServerInfos["dc"];
            ServerInfo serverInfo = serverSetting == null ? null : serverSetting.ToServerInfo();

            PermissionCenterToADSynchronizeSettings config = PermissionCenterToADSynchronizeSettings.GetConfig();

            return(ADHelper.GetInstance(serverInfo));
        }
コード例 #3
0
        internal static string SchemaTypeToPrefix(this SchemaType schemaType)
        {
            string cacheKey = "OguAndADObjectComparerBasePrefix" + "-" + schemaType.ToString();

            return((string)ObjectContextCache.Instance.GetOrAddNewValue(cacheKey, (cache, key) =>
            {
                string prefix = PermissionCenterToADSynchronizeSettings.GetConfig().SchemaMappings.GetSchemaMappingInfo(schemaType.ToString()).Prefix;

                cache.Add(cacheKey, prefix);

                return prefix;
            }));
        }
コード例 #4
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();
            }
        }
コード例 #5
0
        //从配置信息中初始化同步上下文
        private void InitContext(string startPath)
        {
            SynchronizeContext context = SynchronizeContext.Current;

            context.SynchronizeResult = ADSynchronizeResult.Correct;

            //初始化域控制器的配置信息
            ServerInfoConfigureElement serverSetting = ServerInfoConfigSettings.GetConfig().ServerInfos["dc"];
            ServerInfo serverInfo = serverSetting == null ? null : serverSetting.ToServerInfo();

            PermissionCenterToADSynchronizeSettings config = PermissionCenterToADSynchronizeSettings.GetConfig();

            context.SourceRootPath = config.SourceRoot;
            //初始化(权限中心)开始同步的路径和回收站路径
            string path = startPath.IsNullOrEmpty() ? config.DefaultStartPath : startPath;

            if (string.IsNullOrEmpty(path))
            {
                path = context.SourceRootPath;
            }

            if (path != context.SourceRootPath && path.StartsWith(context.SourceRootPath + "\\", StringComparison.Ordinal) == false)
            {
                throw new System.Configuration.ConfigurationErrorsException("开始同步路径必须位于同步根范围内");
            }

            context.StartPath    = path;
            context.RecycleBinOU = config.RecycleBinOU;

            //默认用户口令
            context.DefaultPassword = config.DefaultPassword;

            context.TargetRootOU = config.TargetRootOU;
            context.ADHelper     = ADHelper.GetInstance(serverInfo);

            //初始化权限中心和AD的ID映射关系
            context.ExtendLockTime();
            context.IDMapper.Initialize();

            context.ClearIncludeMappings();

            foreach (ObjectMappingElement elem in config.ObjectMappings)
            {
                context.AddIncludeMapping(elem.SCObjectName, elem.ADObjectName);
            }
        }
コード例 #6
0
        private static OguAndADObjectComparerBase GetComparer(IOguObject oguObject)
        {
            string schemaTypeName = oguObject.ObjectType.ToString();

            string cacheKey = "OguAndADObjectComparerBase" + "-" + schemaTypeName;

            return((OguAndADObjectComparerBase)ObjectContextCache.Instance.GetOrAddNewValue(cacheKey, (cache, key) =>
            {
                SchemaMappingInfo mappingInfo = PermissionCenterToADSynchronizeSettings.GetConfig().SchemaMappings.GetSchemaMappingInfo(schemaTypeName);

                OguAndADObjectComparerBase comparer = (OguAndADObjectComparerBase)PropertyComparersSettings.GetConfig().ObjectComparers[mappingInfo.ComparerName].CreateInstance();

                cache.Add(cacheKey, comparer);

                return comparer;
            }));
        }
コード例 #7
0
ファイル: ADObjectModifier.cs プロジェクト: wooln/AK47Source
        private static string GetADTargetName(IOguObject oguObject)
        {
            SchemaMappingConfigurationElement mappingElement = PermissionCenterToADSynchronizeSettings.GetConfig().SchemaMappings[oguObject.ObjectType.ToString()];

            string prefix     = mappingElement.Prefix;
            string targetName = SynchronizeContext.Current.GetMappedName(oguObject, prefix);

            //string targetOU = SynchronizeContext.Current.TargetRootOU;

            //if (targetOU.IsNotEmpty())
            //{
            //    //???
            //    if (SynchronizeHelper.GetOguObjectDN(oguObject) == targetOU)
            //        targetName = new PathPartEnumerator(SynchronizeContext.Current.TargetRootOU).Last();
            //}

            return(targetName);            //prefix + "=" + ADHelper.EscapeString(targetName);
        }
コード例 #8
0
        protected ObjectModifyType CompareProperties(IOguObject srcObject, ADObjectWrapper targetObject)
        {
            SchemaMappingInfo mappingInfo = PermissionCenterToADSynchronizeSettings.GetConfig().SchemaMappings.GetSchemaMappingInfo(srcObject.ObjectType.ToString());

            ObjectModifyType result = ObjectModifyType.None;

            foreach (ComparerPropertyMappingConfigurationElement propertyComparerElement in mappingInfo.ComparedProperties)
            {
                if (propertyComparerElement.Comparer.Compare(srcObject, propertyComparerElement.Name, targetObject, propertyComparerElement.TargetPropertyName, propertyComparerElement.Context) == false)
                {
                    result = ObjectModifyType.PropertyModified;
                    Trace.Write("(修改的属性Key: " + propertyComparerElement.Name + ")");
                    break;
                }
            }

            return(result);
        }
コード例 #9
0
        public static void Convert(ObjectModifyType modifyType, IOguObject srcObject, DirectoryEntry targetObject)
        {
            SchemaType schemaType           = GetOguSchemaType(targetObject);
            OguAndADObjectSetterBase setter = GetSetter(modifyType, schemaType);

            if (setter != null)
            {
                SchemaMappingInfo mappingInfo = PermissionCenterToADSynchronizeSettings.GetConfig().SchemaMappings.GetSchemaMappingInfo(schemaType.ToString());

                string context = string.Empty;

                if (mappingInfo.ModifyOperations.ContainsKey(modifyType.ToString()))
                {
                    SetterObjectMappingConfigurationElement objSetterMappingElement = mappingInfo.ModifyOperations[modifyType.ToString()];
                    context = objSetterMappingElement.Context;
                }

                setter.Convert(modifyType, srcObject, targetObject, context);
            }
        }
コード例 #10
0
        private static OguAndADObjectSetterBase GetSetter(ObjectModifyType modifyType, SchemaType schemaType)
        {
            string schemaTypeName = schemaType.ToString();

            string cacheKey = "OguAndADObjectSetterBase" + "-" + modifyType.ToString() + "+" + schemaTypeName;

            return((OguAndADObjectSetterBase)ObjectContextCache.Instance.GetOrAddNewValue(cacheKey, (cache, key) =>
            {
                SchemaMappingInfo mappingInfo = PermissionCenterToADSynchronizeSettings.GetConfig().SchemaMappings.GetSchemaMappingInfo(schemaTypeName);

                OguAndADObjectSetterBase setter = null;

                if (mappingInfo.ModifyOperations.ContainsKey(modifyType.ToString()))
                {
                    SetterObjectMappingConfigurationElement objSetterMappingElement = mappingInfo.ModifyOperations[modifyType.ToString()];
                    setter = (OguAndADObjectSetterBase)PropertySettersSettings.GetConfig().ObjectSetters[objSetterMappingElement.OperationName].CreateInstance();
                }

                cache.Add(cacheKey, setter);

                return setter;
            }));
        }