Esempio n. 1
0
        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");
            }
        }
        private void ProvisionPerson(ConnectedMA agent, MVEntry mventry)
        {
            CSEntry        csentry;
            ReferenceValue dn;
            string         accountName;
            string         basePath;
            string         companyName;

            if (agent == null)
            {
                throw new ArgumentNullException(nameof(agent));
            }
            if (mventry == null)
            {
                throw new ArgumentNullException(nameof(mventry));
            }

            try
            {
                accountName = mventry["userPrincipalName"].Value.Split('@')[0];
                basePath    = $"{_users},OU={mventry["company"].Value},{_root}";
                companyName = mventry["company"].Value.Replace(" ", string.Empty);

                dn = agent.CreateDN(
                    $"CN={mventry["displayName"].Value},{basePath}");
                csentry    = agent.Connectors.StartNewConnector("user");
                csentry.DN = dn;
                csentry["company"].Value                   = mventry["company"].Value;
                csentry["displayName"].Value               = mventry["displayName"].Value;
                csentry["givenName"].Value                 = mventry["firstName"].Value;
                csentry["sAMAccountName"].Value            = $"{accountName}_{companyName}";
                csentry["sn"].Value                        = mventry["lastName"].Value;
                csentry["unicodePwd"].Value                = _password;
                csentry["userAccountControl"].IntegerValue = ADS_UF_ACCOUNTDISABLE;
                csentry["userPrincipalName"].Value         = mventry["userPrincipalName"].Value;
                csentry.CommitNewConnector();
            }
            finally
            {
                csentry = null;
                dn      = null;
            }
        }
Esempio n. 3
0
        void IMVSynchronization.Provision(MVEntry mventry)
        {
            switch (mventry.ObjectType.ToLower())
            {
                //Person - MV Object type to scope provision of contoso users to the GALSync domain, as contact objects, under the "ExternalContacts" OU
                #region case "person":
                case "person":
                    {

                        bool bContactsConnected = false; // reset our boolean 
                        bool bProv = false;
                        if (mventry["mail"].IsPresent) bProv = true;
                        maContacts = mventry.ConnectedMAs["GALSync"]; //Declares MA to Provisions

                        int iNumConnectorsContacts = maContacts.Connectors.Count; // count our connectors to this MA 

                        if (bProv)
                        {
                            if (iNumConnectorsContacts > 0) bContactsConnected = true;
                            RDN = "CN=" + mventry["cn"].Value + ",OU=ExternalContacts" + ",DC=GALSync,DC=com";
                            targetDN = maContacts.CreateDN(RDN); //Created the CS DN
                            if (!(bContactsConnected)) //If not found while iNumConnectorsContacts
                            {
                                CSEntry = maContacts.Connectors.StartNewConnector("contact"); //Starts a new connector
                                CSEntry.DN = targetDN; //Sets the CS DN from targetDN
                                CSEntry["targetAddress"].Value = mventry["mail"].Value; //flows mail attribute MV > CS
                                CSEntry.CommitNewConnector(); //commits the connector to cs db
                            }
                        }
                        break;
                    }
                #endregion case "person"

                //GALSyncPerson - MV Obkect type to scope provision of external contacts from the GALSync.com domain to AD in Contoso under the "ExternalContacts" OU
                #region case "GalSyncPerson":
                case galsyncperson":
                    {

                        bool bContactsConnected = false; // reset our boolean 
                        bool bProv = false;
                        if (mventry["mail"].IsPresent) bProv = true;
                        maContacts = mventry.ConnectedMAs["AD MA"]; //Declares MA to Provisions

                        int iNumConnectorsContacts = maContacts.Connectors.Count; // count our connectors to this MA 

                        if (bProv)
                        {
                            if (iNumConnectorsContacts > 0) bContactsConnected = true;
                            RDN = "CN=" + mventry["cn"].Value + ",OU=ExternalContacts" + ",DC=Contoso,DC=com";
                            targetDN = maContacts.CreateDN(RDN); //Created the CS DN
                            if (!(bContactsConnected)) //If not found while iNumConnectorsContacts
                            {
                                CSEntry = maContacts.Connectors.StartNewConnector("contact"); //Starts a new connector
                                CSEntry.DN = targetDN; //Sets the CS DN from targetDN
                                CSEntry["targetAddress"].Value = mventry["mail"].Value; //flows mail attribute MV > CS
                                CSEntry.CommitNewConnector(); //commits the connector to cs db
                            }
                        }
                        break;
                    }
                    #endregion case "GalSyncPerson"
            }
        }