Exemple #1
0
        protected override void InternalProcessRecord()
        {
            GlobalLocatorServiceTenant globalLocatorServiceTenant = new GlobalLocatorServiceTenant();
            GlsDirectorySession        glsDirectorySession        = new GlsDirectorySession();

            globalLocatorServiceTenant.ExternalDirectoryOrganizationId = (Guid)base.Fields["ExternalDirectoryOrganizationId"];
            globalLocatorServiceTenant.ResourceForest = (string)base.Fields["ResourceForest"];
            PartitionId partitionId;
            Exception   ex;

            if (!PartitionId.TryParse(globalLocatorServiceTenant.ResourceForest, out partitionId, out ex))
            {
                base.WriteInvalidFqdnError(globalLocatorServiceTenant.ResourceForest);
            }
            globalLocatorServiceTenant.AccountForest = (string)base.Fields["AccountForest"];
            if (!PartitionId.TryParse(globalLocatorServiceTenant.AccountForest, out partitionId, out ex))
            {
                base.WriteInvalidFqdnError(globalLocatorServiceTenant.AccountForest);
            }
            globalLocatorServiceTenant.PrimarySite       = (string)base.Fields["PrimarySite"];
            globalLocatorServiceTenant.SmtpNextHopDomain = (SmtpDomain)base.Fields["SmtpNextHopDomain"];
            globalLocatorServiceTenant.TenantContainerCN = (string)base.Fields["TenantContainerCN"];
            if (base.Fields.IsModified("TenantFlags"))
            {
                globalLocatorServiceTenant.TenantFlags = (GlsTenantFlags)base.Fields["TenantFlags"];
            }
            glsDirectorySession.AddTenant(globalLocatorServiceTenant.ExternalDirectoryOrganizationId, globalLocatorServiceTenant.ResourceForest, globalLocatorServiceTenant.AccountForest, globalLocatorServiceTenant.SmtpNextHopDomain.Domain, globalLocatorServiceTenant.TenantFlags, globalLocatorServiceTenant.TenantContainerCN, globalLocatorServiceTenant.PrimarySite);
            base.WriteObject(globalLocatorServiceTenant);
        }
        protected override void InternalProcessRecord()
        {
            GlobalLocatorServiceTenant globalLocatorServiceTenant = new GlobalLocatorServiceTenant();
            GlobalLocatorServiceTenant oldGlsTenant        = new GlobalLocatorServiceTenant();
            GlsDirectorySession        glsDirectorySession = new GlsDirectorySession();

            if (base.Fields.IsModified("ExternalDirectoryOrganizationId"))
            {
                Guid guid = (Guid)base.Fields["ExternalDirectoryOrganizationId"];
                if (!glsDirectorySession.TryGetTenantInfoByOrgGuid(guid, out oldGlsTenant))
                {
                    base.WriteGlsTenantNotFoundError(guid);
                }
            }
            else
            {
                SmtpDomain smtpDomain = (SmtpDomain)base.Fields["DomainName"];
                if (!glsDirectorySession.TryGetTenantInfoByDomain(smtpDomain.Domain, out oldGlsTenant))
                {
                    base.WriteGlsDomainNotFoundError(smtpDomain.Domain);
                }
            }
            globalLocatorServiceTenant = this.GetUpdatedGLSTenant(oldGlsTenant);
            glsDirectorySession.UpdateTenant(globalLocatorServiceTenant.ExternalDirectoryOrganizationId, globalLocatorServiceTenant.ResourceForest, globalLocatorServiceTenant.AccountForest, globalLocatorServiceTenant.SmtpNextHopDomain.Domain, globalLocatorServiceTenant.TenantFlags, globalLocatorServiceTenant.TenantContainerCN, globalLocatorServiceTenant.PrimarySite);
        }
        private GlobalLocatorServiceTenant GetUpdatedGLSTenant(GlobalLocatorServiceTenant oldGlsTenant)
        {
            GlobalLocatorServiceTenant globalLocatorServiceTenant = new GlobalLocatorServiceTenant();

            globalLocatorServiceTenant.ExternalDirectoryOrganizationId = oldGlsTenant.ExternalDirectoryOrganizationId;
            globalLocatorServiceTenant.DomainNames = oldGlsTenant.DomainNames;
            if (base.Fields.IsModified("ResourceForest"))
            {
                globalLocatorServiceTenant.ResourceForest = (string)base.Fields["ResourceForest"];
                PartitionId partitionId;
                Exception   ex;
                if (!PartitionId.TryParse(globalLocatorServiceTenant.ResourceForest, out partitionId, out ex))
                {
                    base.WriteInvalidFqdnError(globalLocatorServiceTenant.ResourceForest);
                }
            }
            else
            {
                globalLocatorServiceTenant.ResourceForest = oldGlsTenant.ResourceForest;
            }
            if (base.Fields.IsModified("AccountForest"))
            {
                globalLocatorServiceTenant.AccountForest = (string)base.Fields["AccountForest"];
                PartitionId partitionId2;
                Exception   ex2;
                if (!PartitionId.TryParse(globalLocatorServiceTenant.AccountForest, out partitionId2, out ex2))
                {
                    base.WriteInvalidFqdnError(globalLocatorServiceTenant.AccountForest);
                }
            }
            else
            {
                globalLocatorServiceTenant.AccountForest = oldGlsTenant.AccountForest;
            }
            if (base.Fields.IsModified("PrimarySite"))
            {
                globalLocatorServiceTenant.PrimarySite = (string)base.Fields["PrimarySite"];
            }
            else
            {
                globalLocatorServiceTenant.PrimarySite = oldGlsTenant.PrimarySite;
            }
            if (base.Fields.IsModified("SmtpNextHopDomain"))
            {
                globalLocatorServiceTenant.SmtpNextHopDomain = (SmtpDomain)base.Fields["SmtpNextHopDomain"];
            }
            else
            {
                globalLocatorServiceTenant.SmtpNextHopDomain = oldGlsTenant.SmtpNextHopDomain;
            }
            if (base.Fields.IsModified("TenantFlags"))
            {
                globalLocatorServiceTenant.TenantFlags = (GlsTenantFlags)base.Fields["TenantFlags"];
            }
            else
            {
                globalLocatorServiceTenant.TenantFlags = oldGlsTenant.TenantFlags;
            }
            if (base.Fields.IsModified("TenantContainerCN"))
            {
                globalLocatorServiceTenant.TenantContainerCN = (string)base.Fields["TenantContainerCN"];
            }
            else
            {
                globalLocatorServiceTenant.TenantContainerCN = oldGlsTenant.TenantContainerCN;
            }
            return(globalLocatorServiceTenant);
        }