internal static void RemoveMember(ADObject obj, IRecipientSession session, ADGroup destGroup, WriteVerboseDelegate writeVerbose)
 {
     if (destGroup.Members.Contains(obj.Id))
     {
         destGroup.Members.Remove(obj.Id);
         SetupTaskBase.Save(destGroup, session);
         return;
     }
     writeVerbose(Strings.InfoIsNotMemberOfGroup(obj.DistinguishedName, destGroup.DistinguishedName));
 }
        private ADGroup CreateGroup(IRecipientSession session, ADObjectId containerId, string groupName, LocalizedString groupDescription, GroupTypeFlags groupType)
        {
            ADGroup adgroup = new ADGroup(session, groupName, containerId, groupType);
            MultiValuedProperty <string> multiValuedProperty = new MultiValuedProperty <string>();

            multiValuedProperty.Add(groupDescription);
            adgroup[ADRecipientSchema.Description] = multiValuedProperty;
            adgroup.SamAccountName = groupName;
            SetupTaskBase.Save(adgroup, session);
            base.WriteVerbose(Strings.InfoCreatedGroup(adgroup.DistinguishedName));
            return(adgroup);
        }
 private static void SaveGroup(IRecipientSession session, ADObjectId containerId, ADGroup groupToSave)
 {
     try
     {
         SetupTaskBase.Save(groupToSave, session);
     }
     catch (ADOperationException ex)
     {
         DirectoryOperationException ex2 = ex.InnerException as DirectoryOperationException;
         if (ex2 != null && ex2.Response != null && ex2.Response.ResultCode == ResultCode.UnwillingToPerform)
         {
             throw new UnwillingToPerformException(groupToSave.Name, containerId.DistinguishedName, ex);
         }
         throw;
     }
 }
 private void RemoveServerFromGroup(ADGroup group, IRecipientSession session)
 {
     if (group != null && this.server != null && group.Members.Contains(this.server.Id))
     {
         group.Members.Remove(this.server.Id);
         if (base.ShouldProcess(group.Id.DistinguishedName, Strings.InfoProcessRemoveMember(this.server.Id.DistinguishedName), null))
         {
             SetupTaskBase.Save(group, session);
             base.LogWriteObject(group);
             return;
         }
     }
     else
     {
         this.WriteWarning(Strings.InfoIsNotMemberOfGroup((this.server == null) ? "-" : this.server.Id.DistinguishedName, (group == null) ? "-" : group.Id.DistinguishedName));
     }
 }
 private void FixExchangeTrustedSubsystemGroupMembership(ADGroup ets, ADGroup ewp, ADGroup exs, ADGroup ema, bool etsExisted, bool ewpExisted)
 {
     if (!ewpExisted && etsExisted)
     {
         ets.Members.Remove(exs.Id);
         ADPagedReader <Server> adpagedReader = ((ITopologyConfigurationSession)this.configurationSession).FindAllServersWithVersionNumber(Server.E14MinVersion);
         bool useGlobalCatalog = this.domainConfigurationSession.UseGlobalCatalog;
         this.domainConfigurationSession.UseGlobalCatalog = true;
         foreach (Server server in adpagedReader)
         {
             ADComputer adcomputer = ((ITopologyConfigurationSession)this.domainConfigurationSession).FindComputerByHostName(server.Fqdn);
             if (adcomputer == null)
             {
                 this.WriteWarning(Strings.ErrorCannotFindComputerObjectByServerFqdnNeedManualAdd(server.Fqdn));
             }
             else if (ets.Members.Contains(adcomputer.Id))
             {
                 base.WriteVerbose(Strings.InfoAlreadyIsMemberOfGroup(adcomputer.DistinguishedName, ets.DistinguishedName));
             }
             else
             {
                 ets.Members.Add(adcomputer.Id);
             }
         }
         this.domainConfigurationSession.UseGlobalCatalog = useGlobalCatalog;
         SetupTaskBase.Save(ets, this.rootDomainRecipientSession);
     }
     if (this.adSplitPermissionMode)
     {
         InitializeExchangeUniversalGroups.RemoveMember(ets, this.rootDomainRecipientSession, ewp, new WriteVerboseDelegate(base.WriteVerbose));
     }
     else
     {
         InitializeExchangeUniversalGroups.AddMember(ets, this.rootDomainRecipientSession, ewp, new WriteVerboseDelegate(base.WriteVerbose));
     }
     if (ema.Members.Contains(ets.Id))
     {
         ema.Members.Remove(ets.Id);
         SetupTaskBase.Save(ema, this.rootDomainRecipientSession);
     }
 }
示例#6
0
 private void AddServerToGroup(ADGroup group, IRecipientSession session)
 {
     if (group.Members.Contains(this.server.Id))
     {
         this.WriteWarning(Strings.InfoAlreadyIsMemberOfGroup(this.server.DistinguishedName, group.DistinguishedName));
         return;
     }
     group.Members.Add(this.server.Id);
     if (base.ShouldProcess(group.DistinguishedName, Strings.InfoProcessAddMember(this.server.DistinguishedName), null))
     {
         try
         {
             SetupTaskBase.Save(group, session);
             base.LogWriteObject(group);
         }
         catch (ADOperationException ex)
         {
             this.WriteWarning(Strings.ErrorCouldNotAddGroupMember(group.Id.DistinguishedName, this.server.Id.DistinguishedName, ex.Message));
         }
     }
 }