コード例 #1
0
        public void Provision(MVEntry mventry)
        {
            string          maName = "ADMA";
            ManagementAgent ma     = mventry.ConnectedMAs[maName];

            //begin  changes
            if (mventry.ConnectedMAs[maName].Connectors.Count == 0)
            {
                //provision new AD object
                if (mventry["uid"].IsPresent && mventry["accountName"].IsPresent && mventry["ou"].IsPresent)
                {
                    string         cn        = string.Format("CN={0}", mventry["uid"].StringValue);
                    ReferenceValue dn        = mventry.ConnectedMAs[maName].EscapeDNComponent(cn).Concat(mventry["ou"].StringValue);
                    CSEntry        adCSentry = mventry.ConnectedMAs[maName].Connectors.StartNewConnector("user");
                    adCSentry.DN = dn;
                    string pwd = GenerateRandomString(32);
                    adCSentry["unicodePwd"].Value = pwd;
                    //Log.Debug(pwd);
                    adCSentry["SamAccountName"].StringValue = mventry["AccountName"].StringValue;
                    adCSentry.CommitNewConnector();
                }
            }
            else
            {
                //rename existing AD object
                CSEntry        adCSentry = mventry.ConnectedMAs[maName].Connectors.ByIndex[0];
                ReferenceValue newDn     = mventry.ConnectedMAs[maName].EscapeDNComponent(string.Format("Cn={0}", mventry["uid"].StringValue)).Concat(mventry["ou"].StringValue);
                adCSentry.DN = newDn;
            }
        }
コード例 #2
0
        public override bool IsMet(CSEntry csentry, MVEntry mventry)
        {
            string value = SourceValue(csentry, mventry);

            Tracer.TraceInformation("value-is: {0}", value);
            return(string.IsNullOrEmpty(value) ? false : !Regex.IsMatch(value, Pattern, RegexOptions.IgnoreCase));
        }
コード例 #3
0
        public void MapAttributesForImport(string FlowRuleName, CSEntry csentry, MVEntry mventry)
        {
            AttributeType  type;
            IList <object> sourceValues;
            IList <object> returnValues;

            if (this.MergeValues)
            {
                sourceValues = this.GetSourceValuesFromMultipleConnectorsForImport(csentry, mventry, out type);
            }
            else
            {
                sourceValues = this.GetSourceValuesForImport(csentry, out type);
            }

            if (this.Transforms.Any(t => t.ImplementsLoopbackProcessing))
            {
                IList <object> existingTargetValues = this.GetExistingTargetValuesForImportLoopback(mventry);
                returnValues = Transform.ExecuteTransformChainWithLoopback(this.Transforms, sourceValues, existingTargetValues);
            }
            else
            {
                returnValues = Transform.ExecuteTransformChain(this.Transforms, sourceValues);
            }

            this.SetDestinationAttributeValueForImport(mventry, returnValues, this.MergeValues);
        }
コード例 #4
0
 public override bool IsMet(CSEntry csentry, MVEntry mventry)
 {
     if (Operator.Equals(ConditionOperator.And))
     {
         bool met = true;
         foreach (ConditionBase condition in Conditions)
         {
             met = condition.IsMet(csentry, mventry);
             Tracer.TraceInformation("'And' condition '{0}' returned: {1}", condition.GetType(), met);
             if (met == false)
             {
                 break;
             }
         }
         Tracer.TraceInformation("All 'And' conditions {0} met", met ? "were" : "were not");
         return(met);
     }
     else
     {
         bool met = false;
         foreach (ConditionBase condition in Conditions)
         {
             met = condition.IsMet(csentry, mventry);
             Tracer.TraceInformation("'Or' condition '{0}' returned: {1}", condition.GetType(), met);
             if (met == true)
             {
                 break;
             }
         }
         Tracer.TraceInformation("One or more 'Or' conditions {0} met", met ? "were" : "were not");
         return(met);
     }
 }
コード例 #5
0
        /// <summary>
        /// Route Deprovisioning code through here
        /// </summary>
        /// <param name="csentry"></param>
        /// <param name="mventry"></param>
        /// <returns></returns>
        bool IMVSynchronization.ShouldDeleteFromMV(CSEntry csentry, MVEntry mventry)
        {
            switch (mventry.ObjectType.ToUpper())
            {
            case OBJECTCLASS_PERSON: return(ShouldDeletePerson(csentry, mventry));
            }

            throw new EntryPointNotImplementedException();
        }
コード例 #6
0
        public override bool Evaluate(CSEntry csentry, MVEntry mventry)
        {
            if (csentry == null)
            {
                throw new NotSupportedException(string.Format("The rule type {0} is not supported in this context", this.GetType().Name));
            }

            return(base.Evaluate(csentry[this.Attribute]));
        }
コード例 #7
0
        private bool PassesObjectRules(MVEntry mventry)
        {
            if (Rule.RequiredObjects == null || Rule.RequiredObjects.Length <= 0)
            {
                return(true);
            }

            return(Rule.RequiredObjects.Contains(mventry.ObjectType));
        }
コード例 #8
0
ファイル: RuleEval.cs プロジェクト: jenskaalen/SimpleMIM
        //public static void Execute(FlowRule rule, CSEntry csentry, MVEntry mventry)
        //{

        //}

        public static dynamic GetValue(FlowRule rule, MVEntry entry)
        {
            if (rule.RuleType == ExpressionType.Python)
            {
                var func = Core.GetFlowFunction(rule.Name);
                return(func(entry));
            }

            throw new NotImplementedException();
        }
コード例 #9
0
        /// <summary>
        /// Provisioning - use this only for routing out to individual methods for each object class
        ///
        /// don't forget to use constants instead of "magic strings"
        /// </summary>
        /// <param name="mventry"></param>
        void IMVSynchronization.Provision(MVEntry mventry)
        {
            switch (mventry.ObjectType.ToUpper())
            {
            case OBJECTCLASS_PERSON:    ProvisionPerson(mventry); break;

            default:
                break;
            }
        }
コード例 #10
0
        public override bool Met(MVEntry mventry, CSEntry csentry)
        {
            ConnectedMA MA = mventry.ConnectedMAs[this.ManagementAgentName];

            if (MA.Connectors.Count.Equals(0))
            {
                Tracer.TraceInformation("Condition failed (Reason: Not connected to {0}) {1}", this.ManagementAgentName, this.Description);
                return(false);
            }
            return(true);
        }
コード例 #11
0
ファイル: RuleEval.cs プロジェクト: jenskaalen/SimpleMIM
        public static void Execute(FlowRule rule, MVEntry source, CSEntry target)
        {
            if (rule.RuleType == ExpressionType.Python)
            {
                var func = Core.GetFlowFunction(rule.Name);
                func(source, target);
                return;
            }

            throw new NotImplementedException();
        }
コード例 #12
0
 public bool CanExecute(CSEntry csentry, MVEntry mventry)
 {
     if (this.RuleGroup == null)
     {
         return(true);
     }
     else
     {
         return(this.RuleGroup.Evaluate(csentry, mventry));
     }
 }
コード例 #13
0
        /// <summary>
        /// Handle all provisioning decisions for Person objects
        /// </summary>
        /// <param name="mventry"></param>
        private void ProvisionPerson(MVEntry mventry)
        {
            //-- make all decisions about provisioning here
            //-- then call individual methods for each target system
            bool provision_to_AD = false;

            if (provision_to_AD)
            {
                ProvisionPersonToAD(mventry);
            }
        }
コード例 #14
0
        public override bool Evaluate(CSEntry csentry, MVEntry mventry)
        {
            if (mventry == null)
            {
                throw new NotSupportedException(string.Format("The rule type {0} is not supported in this context", this.GetType().Name));
            }

            int actual = mventry.ConnectedMAs.OfType <ConnectedMA>().Count(t => t.Name == this.MAName);

            return(ComparisonEngine.CompareLong(actual, this.Count, this.Operator));
        }
コード例 #15
0
 public string TargetValue(CSEntry csentry, MVEntry mventry)
 {
     if (Target.Equals(EvaluateAttribute.CSEntry))
     {
         return(csentry[AttributeName].IsPresent ? csentry[AttributeName].Value : null);
     }
     else
     {
         return(mventry[AttributeName].IsPresent ? mventry[AttributeName].Value : null);
     }
 }
コード例 #16
0
        public void MapAttributesForExport(string FlowRuleName, MVEntry mventry, CSEntry csentry)
        {
            FlowRule flowRule = _flows.FirstOrDefault(rule => rule.Name == FlowRuleName);

            if (flowRule == null)
            {
                throw new Exception("Couldnt find flowrule " + FlowRuleName);
            }

            RuleEval.Execute(flowRule, mventry, csentry);
        }
コード例 #17
0
 public bool ShouldFlow(CSEntry csentry, MVEntry mventry)
 {
     if (this.aliasDefinition == null)
     {
         return(true);
     }
     else
     {
         return(this.aliasDefinition.ShouldFlow(csentry, mventry));
     }
 }
コード例 #18
0
        private void SetDestinationAttributeValueForImport(MVEntry mventry, IEnumerable <object> values, bool clearTarget)
        {
            Attrib attribute = mventry[this.TargetAttribute];

            if (clearTarget)
            {
                attribute.Delete();
            }

            this.SetDestinationAttributeValue(attribute, values);
        }
コード例 #19
0
ファイル: FlowRuleAlias.cs プロジェクト: sean-m/umare
 public bool ShouldFlow(CSEntry csentry, MVEntry mventry)
 {
     if (this.RuleGroup == null || this.RuleGroup.Items.Count == 0)
     {
         return(true);
     }
     else
     {
         return(this.RuleGroup.Evaluate(csentry, mventry));
     }
 }
コード例 #20
0
 public override bool Met(MVEntry mventry, CSEntry csentry)
 {
     if (mventry[this.MVAttribute].IsPresent)
     {
         return(true);
     }
     else
     {
         Tracer.TraceInformation("Condition failed (Reason: Metaverse attribute value is not present) {0}", this.Description);
         return(false);
     }
 }
コード例 #21
0
ファイル: ProvisionEval.cs プロジェクト: jenskaalen/SimpleMIM
        public static void ApplyInitialFlows(ProvisionRule rule, CSEntry csentry, MVEntry mventry)
        {
            if (rule.InitialFlows == null)
            {
                return;
            }

            foreach (var initialFlow in rule.InitialFlows)
            {
                RuleEval.Execute(initialFlow, mventry, csentry);
            }
        }
コード例 #22
0
 public override bool Met(MVEntry mventry, CSEntry csentry)
 {
     if (mventry[this.MVAttribute].IsPresent)
     {
         if (mventry[this.MVAttribute].BooleanValue)
         {
             Tracer.TraceInformation("Condition failed (Reason: Boolean value is true) {0}", this.Description);
             return(false);
         }
     }
     return(true);
 }
コード例 #23
0
 public override bool Met(MVEntry mventry, CSEntry csentry)
 {
     if (mventry[this.MVAttribute].IsPresent)
     {
         if (Regex.IsMatch(mventry[this.MVAttribute].Value, this.Pattern, RegexOptions.IgnoreCase))
         {
             Tracer.TraceInformation("Condition failed (Reason: RegEx match) {0}", this.Description);
             return(false);
         }
     }
     return(true); // value not present effectively means not-match
 }
コード例 #24
0
 public override bool Met(MVEntry mventry, CSEntry csentry)
 {
     Tracer.TraceWarning("Condition type 'ConditionAttributeIsNotPresent' is obsolete. Please see documentation.");
     if (!mventry[this.MVAttribute].IsPresent)
     {
         return(true);
     }
     else
     {
         Tracer.TraceInformation("Condition failed (Reason: Metaverse attribute value is present) {0}", this.Description);
         return(false);
     }
 }
コード例 #25
0
        public override void Generate(ConnectedMA ma, CSEntry csentry, MVEntry mventry, Rule rule)
        {
            Tracer.TraceInformation("enter-attributeflowmultivaluedconstant");

            if (Target.Equals("[DN]", StringComparison.OrdinalIgnoreCase))
            {
                throw new InvalidOperationException("Cannot use a multivalued constant flow on the DN of an object");
            }

            if (this.Constants == null)
            {
                throw new ArgumentException("The <Constants> element must be present with one or more values when using a multivalued constant attribute flow rule");
            }

            base.Generate(ma, csentry, mventry, rule);

            try
            {
                foreach (string constant in this.Constants)
                {
                    string escapedCN     = null;
                    string replacedValue = null;
                    replacedValue = constant.ReplaceWithHelperValuesOrBlank(rule.Helpers);

                    if (string.IsNullOrEmpty(this.EscapedCN))
                    {
                        Tracer.TraceInformation("no-CN-to-escape");
                        replacedValue = replacedValue.ReplaceWithMVValueOrBlank(mventry);
                    }
                    else
                    {
                        escapedCN = this.EscapedCN.ReplaceWithHelperValuesOrBlank(rule.Helpers);
                        escapedCN = ma.EscapeDNComponent(this.EscapedCN.ReplaceWithMVValueOrBlank(mventry, "")).ToString();
                        Tracer.TraceInformation("escaped-cn '{0}'", escapedCN);
                        replacedValue = replacedValue.ReplaceWithMVValueOrBlank(mventry, escapedCN);
                    }
                    Tracer.TraceInformation("flow-mv-constant-'{0}'-to-'{1}'", replacedValue, this.Target);

                    csentry[(this.Target)].Values.Add(replacedValue);
                }
            }
            catch (Exception ex)
            {
                Tracer.TraceError("error {0}", ex.GetBaseException());
                throw;
            }
            finally
            {
                Tracer.TraceInformation("exit-attributeflowmutlivaluedconstant");
            }
        }
コード例 #26
0
        internal static bool Compare(MVEntry mventry, CSEntry csentry, string csattributeName, string mvattributeName)
        {
            ReferenceValue csval = null;
            ReferenceValue mvval = null;

            Attrib mvAttrib = mventry[mvattributeName];

            if (csattributeName == "[DN]")
            {
                csval = csentry.DN;
            }
            else
            {
                Attrib csAttrib = csentry[csattributeName];

                if (!csAttrib.IsPresent && !mvAttrib.IsPresent)
                {
                    return(true);
                }

                if (csAttrib.IsPresent ^ mvAttrib.IsPresent)
                {
                    return(false);
                }

                switch (csAttrib.DataType)
                {
                case AttributeType.Reference:
                    csval = csAttrib.ReferenceValue;
                    break;

                case AttributeType.String:
                    csval = csentry.MA.CreateDN(csAttrib.StringValue);
                    break;

                default:
                    Tracer.TraceError("Can only compare string values as DNs");
                    return(false);
                }
            }

            if (mvAttrib.DataType != AttributeType.String)
            {
                Tracer.TraceError("Can only compare string values as DNs");
            }

            mvval = csentry.MA.CreateDN(mvAttrib.StringValue);

            return(mvval.Equals(csval));
        }
コード例 #27
0
        public static string ReplaceWithMVValueOrBlank(this string source, MVEntry mventry, string escapedCN)
        {
            source = Regex.Replace(source, @"#param:EscapedCN#", escapedCN ?? "", RegexOptions.IgnoreCase);
            MatchCollection mc = Regex.Matches(source, @"(?<=#mv\:)(?<attrname>\w+)#", RegexOptions.Compiled);

            foreach (Match match in mc)
            {
                string matchValue = match.Value.Trim('#');
                string newValue   = mventry[matchValue].IsPresent ? mventry[matchValue].Value : "";
                Tracer.TraceInformation("replaced-'{0}'-with-'{1}'", matchValue, newValue);
                source = Regex.Replace(source, string.Format(@"#mv\:{0}", match.Value), mventry[matchValue].Value);
            }
            return(source);
        }
コード例 #28
0
ファイル: FIM.MRE.cs プロジェクト: sorengranfeldt/mre
        private void ConditionalRenameConnector(ConnectedMA ma, CSEntry csentry, MVEntry mventry, Rule connectorRule)
        {
            Tracer.TraceInformation("enter-conditionalrenameconnector");
            try
            {
                if (connectorRule.ConditionalRename == null)
                {
                    return;
                }

                string escapedCN     = null;
                string replacedValue = null;
                if (string.IsNullOrEmpty(connectorRule.ConditionalRename.EscapedCN))
                {
                    Tracer.TraceInformation("no-cn-to-escape");
                    replacedValue = connectorRule.ConditionalRename.NewDNValue.ReplaceWithMVValueOrBlank(mventry);
                }
                else
                {
                    escapedCN = ma.EscapeDNComponent(connectorRule.ConditionalRename.EscapedCN.ReplaceWithMVValueOrBlank(mventry, "")).ToString();
                    Tracer.TraceInformation("escaped-cn {0}", escapedCN);
                    replacedValue = connectorRule.ConditionalRename.NewDNValue.ReplaceWithMVValueOrBlank(mventry, escapedCN);
                }

                ReferenceValue newdn = ma.CreateDN(replacedValue);
                ReferenceValue olddn = ma.CreateDN(csentry.DN.ToString());
                Tracer.TraceInformation("old-dn '{0}'", olddn.ToString());
                Tracer.TraceInformation("new-dn '{0}'", newdn.ToString());

                if (this.AreDNsEqual(olddn, newdn, ma, connectorRule.ConditionalRename.StrictDNCompare))
                {
                    Tracer.TraceInformation("no-renaming-necessary");
                }
                else
                {
                    Tracer.TraceInformation("dn-rename-required");
                    csentry.DN = newdn;
                }
            }
            catch (Exception ex)
            {
                Tracer.TraceError("error {0}", ex.GetBaseException());
                throw;
            }
            finally
            {
                Tracer.TraceInformation("exit-conditionalrenameconnector");
            }
        }
コード例 #29
0
 private void FlowReferenceAttribute(CSEntry csentry, MVEntry mventry, bool targetIsDN, AttributeType targetType)
 {
     if (targetType == AttributeType.Reference)
     {
         csentry[this.Target].ReferenceValue = mventry[this.Source].ReferenceValue;
     }
     else if (targetType == AttributeType.String)
     {
         csentry[this.Target].StringValue = mventry[this.Source].ReferenceValue.ToString();
     }
     else
     {
         throw new InvalidOperationException(string.Format("Cannot convert reference source value to target type {0}", targetType));
     }
 }
コード例 #30
0
        /// <summary>
        /// Routing function that takes the flow-rule-name and calls out to the appropriate method to handle
        /// the required flowrule
        ///
        /// do *NOT* just drop everything into a single monolithic switch statement as it's horrible to work with
        /// and make use of constants rather than magic strings wherever possible
        ///
        /// when creating flow rules, avoid using generic rules and try to employ a verb-noun style structure
        /// so our flow rules are creating meaning rather than just functioning as a place-holder for routing
        /// </summary>
        /// <param name="FlowRuleName"></param>
        /// <param name="mventry"></param>
        /// <param name="csentry"></param>
        void IMASynchronization.MapAttributesForExport(string FlowRuleName, MVEntry mventry, CSEntry csentry)
        {
            switch (FlowRuleName.ToUpper())
            {
            //-- example call out for the SAMPLE_FLOW_RULE
            case SAMPLE_RULE_NAME: sampleEAF(mventry, csentry); break;

            default:
                //-- if we haven't got a handler in place, then throw an exception and log the object type so we've
                //-- got a record of which object failed and why both out to the log *and* in the MIM Console
                string message = string.Format("Unexpected export flow rule - {0}", FlowRuleName);
                logger.Error(message);
                throw new EntryPointNotImplementedException(message);
            }
        }
コード例 #31
0
        void ProvisionUPSA(MVEntry mventry, string MA_name)
        {
            var attr_map = new Dictionary<string, string>()
            {
                {"accountName",     "AccountName"},
                {"department",      "Department"},
                {"displayName",     "UserName"},
                {"mail",            "WorkEmail"},
                {"objectSid",       "SID"},
                {"lastName",        "LastName"},
                {"firstName",       "FirstName"},
                {"telephoneNumber", "WorkPhone"},
            };

            ConnectedMA ManagementAgent = mventry.ConnectedMAs[MA_name];
            int Connectors = ManagementAgent.Connectors.Count;

            if (0 == Connectors && mventry.ObjectType.Equals("person", StringComparison.OrdinalIgnoreCase))
            {
                if (mventry["accountName"].IsPresent)
                {
                    string anchor = mventry["accountName"].Value;
                    CSEntry csentry = ManagementAgent.Connectors.StartNewConnector("user");

                    AttributeNameEnumerator iter = mventry.GetEnumerator();
                    while (iter.MoveNext())
                    {
                        string CS_AttrName;
                        if (attr_map.TryGetValue(iter.Current, out CS_AttrName))
                        {
                            csentry[CS_AttrName].Value = mventry[iter.Current].Value;
                        }
                    }
                    csentry["Anchor"].Value = anchor;
                    csentry.CommitNewConnector();
                }
            }
            if (mventry.ObjectType.ToLower() == "group" && 0 == Connectors)
            {
                try
                {
                    if (mventry["accountName"].IsPresent)
                    {
                        string anchor = mventry["accountName"].Value;
                        CSEntry csentry = ManagementAgent.Connectors.StartNewConnector("group");
                        csentry["Anchor"].Value = anchor;
                        csentry.CommitNewConnector();

                    }
                }
                catch (ObjectAlreadyExistsException)
                {
                    // Suppress the exception when an object exists with same distinguished name in the connector space.
                    // The object should join on the next inbound synchronization run
                }

            }
            if (mventry.ObjectType.ToLower() == "contact" && 0 == Connectors)
            {
                try
                {
                    if (mventry["sAMAccountName"].IsPresent)
                    {
                        string anchor = mventry["sAMAccountName"].Value;
                        CSEntry csentry = ManagementAgent.Connectors.StartNewConnector("contact");
                        csentry["Anchor"].Value = anchor;
                        csentry.CommitNewConnector();
                    }
                }
                catch (ObjectAlreadyExistsException)
                {
                    // Suppress the exception when an object exists with same distinguished name in the connector space.
                    // The object should join on the next inbound synchronization run
                }
            }
        }
コード例 #32
0
 /// <summary>
 /// IMVSynchronization.ShouldDeleteFromMV
 /// Determines if the metaverse object should be deleted along with the connector space object 
 /// after a connector space object has been disconnected from a metaverse object during inbound 
 /// synchronization. The Identity Integration Server calls this method when an object deletion rule, 
 /// which was configured in Identity Manager to use a rules extension, is triggered.
 /// </summary>
 /// <param name="csentry"></param>
 /// <param name="mventry"></param>
 /// <returns></returns>
 bool IMVSynchronization.ShouldDeleteFromMV(CSEntry csentry, MVEntry mventry)
 {
     throw new EntryPointNotImplementedException();
 }
コード例 #33
0
 /// <summary>
 /// IMVSynchronization.Provision
 /// Evaluates connected objects in response to changes to a metaverse object. 
 /// The Identity Integration Server calls this method during a management agent run 
 /// when synchronization rules cause a change in the metaverse object.
 /// </summary>
 /// <param name="mventry"></param>
 void IMVSynchronization.Provision(MVEntry mventry)
 {
     ProvisionUPSA(mventry, "SPMA");
 }
コード例 #34
0
        /// <summary>
        /// The MapAttributesForExport method is called to map attributes from a metaverse entry to a connector space entry.
        /// </summary>
        /// <param name="FlowRuleName">
        /// Contains the name of the flow rule. You must use only alphanumeric characters for the FlowRuleName parameter, 
        /// otherwise you can encounter problems in a rules extension.
        /// Note:  Flow rules are not executed in the order shown in Identity Manager. 
        /// Identity Integration Server uses these rules according to the state of the metaverse object. 
        /// Configure your rules based on the state of the object rather than the rules being called in a predetermined order.
        /// </param>
        /// <param name="mventry">Contains an MVEntry object that represents the source metaverse entry.</param>
        /// <param name="csentry">Contains a CSEntry object that represents the destination connector space entry.</param>
        /// <remarks>
        /// This method is called when:
        ///   - the export flow rules do not overlap with the import flow rules or
        ///   - if the source attribute has a precedence greater than or equal to the precedence of the overlapping import flow rule. 
        ///     Management agent precedence is set in Metaverse Designer.
        /// </remarks>
        void IMASynchronization.MapAttributesForExport(string FlowRuleName, MVEntry mventry, CSEntry csentry)
        {
            string ruleName;
            string mvAttribute;
            string csAttribute;
            switch (FlowRuleName)
            {
                case "GetDomain:distinguishedName,domain":
                    // This flow rule is to correctly populate the ProfileIdentifier attribute in the SharePoint Connectorspace object.


                    try
                    {
                        GetFlowRuleParameters(FlowRuleName, out ruleName, out mvAttribute, out csAttribute);

                        // TODO: ComesFromID helps us not initializing the domain property if the account comes from LDAP.
                        // It does not help however in the cases of claim based accounts when the domain cannot be importe back
                        // with full import. We need another way to create account names.
                        string domain = GetDomainValue(mventry[mvAttribute].Value);
                        if (string.IsNullOrEmpty(domain))
                        {
                            /*
                             if (csentry[csAttribute].IsPresent)
                             {
                                 csentry[csAttribute].Values.Clear();
                             }
                             */
                        }
                        else
                        {
                            csentry["ProfileIdentifier"].Value = domain + "\\" + mventry["accountName"].Value;
                        }
                    }
                    catch (Exception e)
                    {
                        // For some reason the date was not able to be converted and
                        // an exception occured. Throw decline of mapping which will 
                        // either use a lower precedence mapping or will 
                        // skip the mapping for this attribute.
                        // However, it will not stop the run.
                        //  throw new DeclineMappingException();
                        throw new UnexpectedDataException("Error while processing Set-SPS-ProfileIdentifier-Out rule extension: " + e.ToString(), e);
                    }
                    break;

                case "GetDisplayName:displayName,PreferredName":
                    try
                    {
                        GetFlowRuleParameters(FlowRuleName, out ruleName, out mvAttribute, out csAttribute);
                        // First try to get the name from the designated attribute
                        string displayName = null;
                        if (mventry[mvAttribute].IsPresent)
                            displayName = mventry[mvAttribute].Value.Trim();
                        if (string.IsNullOrEmpty(displayName))
                        {
                            // The attribute is NULL. Get the name from the distinguishedName.
                            displayName = GetDisplayNameFromDistinguishedName(mventry["distinguishedName"].Value);
                        }
                        if (string.IsNullOrEmpty(displayName))
                        {
                            if (csentry[csAttribute].IsPresent)
                            {
                                csentry[csAttribute].Values.Clear();
                            }
                        }
                        else
                        {
                            csentry[csAttribute].Value = displayName;
                        }
                    }
                    catch (Exception)
                    {
                        // For some reason the date was not able to be converted and
                        // an exception occured. Throw decline of mapping which will 
                        // either use a lower precedence mapping or will 
                        // skip the mapping for this attribute.
                        // However, it will not stop the run.
                        throw new DeclineMappingException();
                    }
                    break;
            }


        }
コード例 #35
0
        /// <summary>
        /// The MapAttributesForImport method is called to map attributes from a connector space entry to a metaverse entry.
        /// </summary>
        /// <param name="FlowRuleName">Contains the name of the flow rule. You must use only alphanumeric characters for the FlowRuleName parameter, otherwise you can encounter problems in a rules extension.</param>
        /// <param name="csentry">Contains a CSEntry object that represents the source connector space entry.</param>
        /// <param name="mventry">Contains an MVEntry object that represents the destination metaverse entry.</param>
        void IMASynchronization.MapAttributesForImport(string FlowRuleName, CSEntry csentry, MVEntry mventry)
        {
            string ruleName;
            string csAttribute;
            string mvAttribute;

            switch (FlowRuleName)
            {
                case "DomainSIDToString":
                    try
                    {
                        if (csentry["objectSID"].IsPresent)
                        {
                            mventry["stringSID"].Value = Utils.ConvertSidToString(csentry["objectSID"].BinaryValue);
                        }
                    }
                    catch (Exception e)
                    {
                        throw new UnexpectedDataException("Error while processing DomainSIDToString rule extension: " + e.ToString(), e);
                    }
                    break;

                case "ConvertToString:nCName,nCName":

                    GetFlowRuleParameters(FlowRuleName, out ruleName, out csAttribute, out mvAttribute);
                    // Used to convert Reference to string DN
                    mventry[mvAttribute].Value = csentry[csAttribute].Value.ToString();
                    break;

                case "ProxyAddressesToSipAddress:proxyAddresses,SPS-SipAddress":
                    // Used to get the Sip Address from the ProxyAddresses attribute

                    GetFlowRuleParameters(FlowRuleName, out ruleName, out csAttribute, out mvAttribute);
                    try
                    {
                        String[] valueArray;
                        if (csentry[csAttribute].IsPresent)
                        {
                            // Usually proxy address is multivalue, but just in case it is checked here and handled accordingly
                            if (csentry[csAttribute].IsMultivalued == true)
                            {
                                valueArray = csentry[csAttribute].Values.ToStringArray();
                            }
                            else
                            {
                                valueArray = new String[1] { csentry[csAttribute].Value };
                            }
                            foreach (String value in valueArray)
                            {
                                if (value.StartsWith("sip:", StringComparison.OrdinalIgnoreCase) == true)
                                {
                                    mventry[mvAttribute].Value = value.Substring(4); // remove the "sip:"
                                    break;
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        throw new UnexpectedDataException("Error while processing ProxyAddressesToSipAddress rule extension: " + e.ToString(), e);
                    }
                    break;

            }
        }
コード例 #36
0
 /// <summary>
 /// The ResolveJoinSearch method is called when a join rule is configured to use a rules extension to resolve conflicts, and when one or more results from a metaverse search match the values that are generated by the IMASynchronization.MapAttributesForJoin method.
 /// </summary>
 /// <param name="joinCriteriaName">Contains a string that contains the name of the join criteria. You must use only alphanumeric characters for the joinCriteriaName parameter, otherwise you can encounter problems in a rules extension.</param>
 /// <param name="csentry">Contains the CSEntry object that represents the connector space entry that will be joined to the metaverse entry.</param>
 /// <param name="rgmventry">Contains an array of MVEntry objects that represent the metaverse entries that match the join operation criteria. On return, the imventry parameter receives the index of the object in this array to which the connector space entry will be joined.</param>
 /// <param name="imventry">If the method returns True, this parameter receives the index of the object in the rgmventry parameter to which the connector space entry will be joined.</param>
 /// <param name="MVObjectType">Contains a string that contains the name of the metaverse class.</param>
 /// <returns></returns>
 bool IMASynchronization.ResolveJoinSearch(string joinCriteriaName, CSEntry csentry, MVEntry[] rgmventry, out int imventry, ref string MVObjectType)
 {
     throw new EntryPointNotImplementedException();
 }