Exemple #1
0
		private void VerifyMandatoryPropertiesAppliable(ADUser mailbox)
		{
			if (this.needApplyMandatoryProperties)
			{
				return;
			}
			string serverLegacyDN;
			if (mailbox != null)
			{
				serverLegacyDN = mailbox.ServerLegacyDN;
			}
			else
			{
				TPublicObject instance = this.Instance;
				serverLegacyDN = instance.ServerLegacyDN;
			}
			if (!string.IsNullOrEmpty(serverLegacyDN))
			{
				AdministrativeGroup administrativeGroup = base.GlobalConfigSession.GetAdministrativeGroup();
				if (serverLegacyDN.StartsWith(administrativeGroup.LegacyExchangeDN + "/"))
				{
					this.needApplyMandatoryProperties = true;
					return;
				}
				TIdentity identity = this.Identity;
				LocalizedException exception = new TaskInvalidOperationException(Strings.ErrorNoNeedApplyMandatoryProperties(identity.ToString()));
				ExchangeErrorCategory category = ExchangeErrorCategory.Client;
				TPublicObject instance2 = this.Instance;
				base.WriteError(exception, category, instance2.Id);
			}
		}
Exemple #2
0
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     base.InternalValidate();
     if (string.IsNullOrEmpty(this.DataObject.LegacyExchangeDN))
     {
         AdministrativeGroup administrativeGroup = base.GlobalConfigSession.GetAdministrativeGroup();
         string parentLegacyDN = string.Format(CultureInfo.InvariantCulture, "{0}/cn=Recipients", new object[]
         {
             administrativeGroup.LegacyExchangeDN
         });
         this.DataObject.LegacyExchangeDN = LegacyDN.GenerateLegacyDN(parentLegacyDN, this.DataObject, true, new LegacyDN.LegacyDNIsUnique(this.LegacyDNIsUnique));
     }
     if (!VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).CmdletInfra.EmailAddressPolicy.Enabled)
     {
         this.DataObject.EmailAddressPolicyEnabled = false;
     }
     DistributionGroupTaskHelper.CheckModerationInMixedEnvironment(this.DataObject, new Task.TaskWarningLoggingDelegate(this.WriteWarning), Strings.WarningLegacyExchangeServer);
     TaskLogger.LogExit();
 }
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            QueryFilter filter = null;

            if (base.Fields.IsModified("AdministrativeGroup"))
            {
                filter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, this.AdministrativeGroup);
            }
            IEnumerable <AdministrativeGroup> enumerable = this.configurationSession.FindPaged <AdministrativeGroup>(null, QueryScope.SubTree, filter, null, 0);
            IEnumerator <AdministrativeGroup> enumerator = enumerable.GetEnumerator();

            if (enumerator == null || !enumerator.MoveNext())
            {
                if (base.Fields.IsModified("AdministrativeGroup"))
                {
                    base.WriteError(new AdminGroupNotFoundException(this.AdministrativeGroup), ErrorCategory.ObjectNotFound, null);
                }
                else
                {
                    base.WriteError(new AdminGroupsNotFoundException(), ErrorCategory.ObjectNotFound, null);
                }
            }
            SecurityIdentifier sid = this.exs.Sid;
            SecurityIdentifier securityIdentifier = new SecurityIdentifier("AU");
            SecurityIdentifier identity           = new SecurityIdentifier("SY");
            Guid schemaClassGuid = DirectoryCommon.GetSchemaClassGuid(this.configurationSession, "msExchExchangeServer");
            List <ActiveDirectoryAccessRule> list = new List <ActiveDirectoryAccessRule>();

            list.Add(new ActiveDirectoryAccessRule(this.eoa.Sid, ActiveDirectoryRights.ExtendedRight, AccessControlType.Allow, WellKnownGuid.RecipientUpdateExtendedRightGuid, ActiveDirectorySecurityInheritance.Descendents, schemaClassGuid));
            list.Add(new ActiveDirectoryAccessRule(identity, ActiveDirectoryRights.ExtendedRight, AccessControlType.Allow, WellKnownGuid.RecipientUpdateExtendedRightGuid, ActiveDirectorySecurityInheritance.Descendents, schemaClassGuid));
            GenericAce[] aces = new GenericAce[]
            {
                new ObjectAce(AceFlags.None, AceQualifier.AccessAllowed, 256, securityIdentifier, ObjectAceFlags.ObjectAceTypePresent, WellKnownGuid.CreatePublicFolderExtendedRightGuid, Guid.Empty, false, null)
            };
            do
            {
                AdministrativeGroup administrativeGroup = enumerator.Current;
                base.LogReadObject(administrativeGroup);
                if (base.ShouldProcess(administrativeGroup.DistinguishedName, Strings.InfoProcessAction(this.eoa.Sid.ToString()), null))
                {
                    DirectoryCommon.SetAces(new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), null, administrativeGroup, list.ToArray());
                }
                DirectoryCommon.SetAclOnAlternateProperty(administrativeGroup, aces, AdministrativeGroupSchema.PublicFolderDefaultAdminAcl);
                if (base.ShouldProcess(administrativeGroup.DistinguishedName, Strings.InfoProcessAction(securityIdentifier.ToString()), null))
                {
                    this.configurationSession.Save(administrativeGroup);
                }
                PublicFolderTree[] array = this.configurationSession.Find <PublicFolderTree>(administrativeGroup.Id, QueryScope.SubTree, new ComparisonFilter(ComparisonOperator.Equal, PublicFolderTreeSchema.PublicFolderTreeType, PublicFolderTreeType.Mapi), null, 0);
                if (array.Length == 0)
                {
                    base.WriteVerbose(Strings.InfoCouldNotFindMAPITLHInAdminGroup(administrativeGroup.AdminDisplayName));
                }
                else
                {
                    PublicFolderTree publicFolderTree = array[0];
                    base.LogReadObject(publicFolderTree);
                    DirectoryCommon.SetAclOnAlternateProperty(publicFolderTree, aces, AdministrativeGroupSchema.PublicFolderDefaultAdminAcl);
                    if (base.ShouldProcess(publicFolderTree.DistinguishedName, Strings.InfoProcessAction(securityIdentifier.ToString()), null))
                    {
                        this.configurationSession.Save(publicFolderTree);
                    }
                }
                ActiveDirectoryAccessRule ace = new ActiveDirectoryAccessRule(sid, ActiveDirectoryRights.ExtendedRight, AccessControlType.Deny, WellKnownGuid.ReceiveAsExtendedRightGuid, ActiveDirectorySecurityInheritance.All);
                this.SetAceByObjectClass <ServersContainer>(administrativeGroup.Id, ace);
            }while (enumerator.MoveNext());
            TaskLogger.LogExit();
        }