Esempio n. 1
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter(new object[]
     {
         this.DataObject
     });
     this.IsSetRandomPassword = false;
     if (this.DataObject.IsChanged(MailboxSchema.WindowsLiveID))
     {
         this.IsSetRandomPassword = true;
         if (this.DataObject.IsChanged(MailboxSchema.NetID))
         {
             MailboxTaskHelper.IsLiveIdExists((IRecipientSession)base.DataSession, this.DataObject.WindowsLiveID, this.DataObject.NetID, new Task.ErrorLoggerDelegate(base.WriteError));
         }
     }
     if (base.Fields.IsModified("SKUCapability"))
     {
         this.DataObject.SKUCapability = new Capability?(this.SKUCapability);
     }
     if (base.Fields.IsModified("AddOnSKUCapability"))
     {
         CapabilityHelper.SetAddOnSKUCapabilities(this.AddOnSKUCapability, this.DataObject.PersistedCapabilities);
         RecipientTaskHelper.UpgradeArchiveQuotaOnArchiveAddOnSKU(this.DataObject, this.DataObject.PersistedCapabilities);
     }
     if (this.IsChangingOnPassword && this.HasSetPasswordPermission)
     {
         ((IRecipientSession)base.DataSession).SetPassword(this.DataObject, this.Password);
     }
     base.InternalProcessRecord();
     TaskLogger.LogExit();
 }
        protected virtual void PrepareRecipientObject(ref TDataObject dataObject)
        {
            ADUser aduser = dataObject as ADUser;

            if (aduser != null)
            {
                if (base.Fields.IsModified("SKUCapability"))
                {
                    aduser.SKUCapability = new Capability?(this.SKUCapability);
                }
                if (base.Fields.IsModified("AddOnSKUCapability"))
                {
                    CapabilityHelper.SetAddOnSKUCapabilities(this.AddOnSKUCapability, aduser.PersistedCapabilities);
                    RecipientTaskHelper.UpgradeArchiveQuotaOnArchiveAddOnSKU(aduser, aduser.PersistedCapabilities);
                }
                if (base.Fields.IsModified(ADRecipientSchema.SKUAssigned))
                {
                    aduser.SKUAssigned = new bool?(this.SKUAssigned);
                }
                if (base.Fields.IsModified(ADRecipientSchema.UsageLocation))
                {
                    aduser.UsageLocation = this.UsageLocation;
                }
            }
        }
Esempio n. 3
0
        protected override void PrepareRecipientObject(ADUser user)
        {
            TaskLogger.LogEnter();
            string userPrincipalName = user.UserPrincipalName;

            base.PrepareRecipientObject(user);
            bool flag = base.Fields.Contains("SoftDeletedObject");

            if (flag && userPrincipalName != user.UserPrincipalName)
            {
                user.UserPrincipalName = userPrincipalName;
            }
            using (new CmdletMonitoredScope(base.CurrentTaskContext.UniqueId, "BizLogic", "NewUserBase.PrepareUserObject", LoggerHelper.CmdletPerfMonitors))
            {
                this.PrepareUserObject(user);
            }
            if (!string.IsNullOrEmpty(this.ImmutableId))
            {
                this.DataObject.ImmutableId = this.ImmutableId;
            }
            if (base.IsDebugOn)
            {
                base.WriteDebug(Strings.DebugStartUpnUniquenessCheck);
            }
            using (new CmdletMonitoredScope(base.CurrentTaskContext.UniqueId, "BizLogic", "RecipientTaskHelper.IsUserPrincipalNameUnique", LoggerHelper.CmdletPerfMonitors))
            {
                RecipientTaskHelper.IsUserPrincipalNameUnique(base.TenantGlobalCatalogSession, user, user.UserPrincipalName, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), ExchangeErrorCategory.ServerOperation, !flag);
            }
            if (base.IsDebugOn)
            {
                base.WriteDebug(Strings.DebugEndUpnUniquenessCheck);
            }
            if (!string.IsNullOrEmpty(user.SamAccountName))
            {
                using (new CmdletMonitoredScope(base.CurrentTaskContext.UniqueId, "BizLogic", "RecipientTaskHelper.IsSamAccountNameUnique", LoggerHelper.CmdletPerfMonitors))
                {
                    RecipientTaskHelper.IsSamAccountNameUnique(base.TenantGlobalCatalogSession, user, user.SamAccountName, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), ExchangeErrorCategory.Client, !flag);
                    goto IL_2C1;
                }
            }
            bool useRandomSuffix = this.WindowsLiveID != null && this.WindowsLiveID.SmtpAddress != SmtpAddress.Empty;

            if (base.IsDebugOn)
            {
                base.WriteDebug(Strings.DebugStartGeneratingUniqueSamAccountName);
            }
            using (new CmdletMonitoredScope(base.CurrentTaskContext.UniqueId, "BizLogic", "RecipientTaskHelper.PrepareRecipientObject/VariantConfiguration", LoggerHelper.CmdletPerfMonitors))
            {
                IRecipientSession[] recipientSessions = new IRecipientSession[]
                {
                    base.RootOrgGlobalCatalogSession
                };
                if (VariantConfiguration.InvariantNoFlightingSnapshot.CmdletInfra.ServiceAccountForest.Enabled && base.CurrentOrganizationId != OrganizationId.ForestWideOrgId)
                {
                    recipientSessions = new IRecipientSession[]
                    {
                        base.RootOrgGlobalCatalogSession,
                        base.PartitionOrRootOrgGlobalCatalogSession
                    };
                }
                using (new CmdletMonitoredScope(base.CurrentTaskContext.UniqueId, "BizLogic", "RecipientTaskHelper.GenerateUniqueSamAccountName", LoggerHelper.CmdletPerfMonitors))
                {
                    user.SamAccountName = RecipientTaskHelper.GenerateUniqueSamAccountName(recipientSessions, user.Id.DomainId, RecipientTaskHelper.GetLocalPartOfUserPrincalName(user.UserPrincipalName), false, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), useRandomSuffix);
                }
            }
            if (base.IsDebugOn)
            {
                base.WriteDebug(Strings.DebugEndGeneratingUniqueSamAccountName);
            }
IL_2C1:
            if (string.IsNullOrEmpty(user.Alias))
            {
                using (new CmdletMonitoredScope(base.CurrentTaskContext.UniqueId, "BizLogic", "RecipientTaskHelper.GenerateUniqueAlias", LoggerHelper.CmdletPerfMonitors))
                {
                    user.Alias = RecipientTaskHelper.GenerateUniqueAlias(base.TenantGlobalCatalogSession, user.OrganizationId, string.IsNullOrEmpty(user.UserPrincipalName) ? user.SamAccountName : RecipientTaskHelper.GetLocalPartOfUserPrincalName(user.UserPrincipalName), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
                }
            }
            if (base.Fields.IsModified("SKUCapability"))
            {
                user.SKUCapability = new Capability?(this.SKUCapability);
            }
            if (base.Fields.IsModified("AddOnSKUCapability"))
            {
                CapabilityHelper.SetAddOnSKUCapabilities(this.AddOnSKUCapability, user.PersistedCapabilities);
                RecipientTaskHelper.UpgradeArchiveQuotaOnArchiveAddOnSKU(user, user.PersistedCapabilities);
            }
            if (base.Fields.IsModified(ADRecipientSchema.SKUAssigned))
            {
                user.SKUAssigned = new bool?(this.SKUAssigned);
            }
            TaskLogger.LogExit();
        }