protected override void InternalProcessRecord()
 {
     try
     {
         using (PublicFolderDataProvider publicFolderDataProvider = new PublicFolderDataProvider(this.ConfigurationSession, "Disable-MailPublicFolder", Guid.Empty))
         {
             if (!string.IsNullOrWhiteSpace(base.DataObject.EntryId))
             {
                 StoreObjectId storeObjectId = StoreObjectId.FromHexEntryId(base.DataObject.EntryId);
                 PublicFolder  publicFolder  = (PublicFolder)publicFolderDataProvider.Read <PublicFolder>(new PublicFolderId(storeObjectId));
                 publicFolder.MailEnabled = false;
                 publicFolder.ProxyGuid   = Guid.Empty.ToByteArray();
                 publicFolderDataProvider.Save(publicFolder);
             }
         }
     }
     catch (AccessDeniedException exception)
     {
         base.WriteError(exception, ExchangeErrorCategory.Authorization, this.Identity);
     }
     catch (ObjectNotFoundException ex)
     {
         this.WriteWarning(Strings.FailedToLocatePublicFolder(this.Identity.ToString(), ex.ToString()));
     }
     base.InternalProcessRecord();
 }
        private bool IsValidToUpdateEntryId(string entryId, out ADObjectId contentMailbox)
        {
            contentMailbox = null;
            if (string.IsNullOrEmpty(entryId))
            {
                return(false);
            }
            if (StringComparer.OrdinalIgnoreCase.Equals(entryId, this.DataObject.EntryId))
            {
                return(false);
            }
            StoreObjectId storeObjectId = null;

            try
            {
                storeObjectId = StoreObjectId.FromHexEntryId(entryId);
            }
            catch (FormatException innerException)
            {
                base.WriteError(new RecipientTaskException(Strings.ErrorSetMailPublicFolderEntryIdWrongFormat(entryId), innerException), ExchangeErrorCategory.Client, this.DataObject.Identity);
            }
            using (PublicFolderDataProvider publicFolderDataProvider = new PublicFolderDataProvider(this.ConfigurationSession, "Set-MailPublicFolder", Guid.Empty))
            {
                Guid exchangeGuid = Guid.Empty;
                try
                {
                    PublicFolder publicFolder = (PublicFolder)publicFolderDataProvider.Read <PublicFolder>(new PublicFolderId(storeObjectId));
                    exchangeGuid = publicFolder.ContentMailboxGuid;
                }
                catch (ObjectNotFoundException innerException2)
                {
                    base.WriteError(new RecipientTaskException(Strings.ErrorSetMailPublicFolderEntryIdNotExist(entryId), innerException2), ExchangeErrorCategory.Client, this.DataObject.Identity);
                }
                ADRecipient adrecipient = base.TenantGlobalCatalogSession.FindByExchangeGuid(exchangeGuid);
                if (adrecipient != null)
                {
                    contentMailbox = adrecipient.Id;
                }
                if (string.IsNullOrEmpty(this.DataObject.EntryId))
                {
                    return(true);
                }
                StoreObjectId storeObjectId2 = StoreObjectId.FromHexEntryId(this.DataObject.EntryId);
                try
                {
                    PublicFolder publicFolder2 = (PublicFolder)publicFolderDataProvider.Read <PublicFolder>(new PublicFolderId(storeObjectId2));
                }
                catch (ObjectNotFoundException)
                {
                    return(true);
                }
                if (ArrayComparer <byte> .Comparer.Equals(storeObjectId2.LongTermFolderId, storeObjectId.LongTermFolderId))
                {
                    return(true);
                }
            }
            return(false);
        }
Example #3
0
        // Token: 0x060007E3 RID: 2019 RVA: 0x000392E8 File Offset: 0x000374E8
        private StoreObjectId StoreObjectIdFromParameters(string parameters)
        {
            StoreObjectId storeObjectId = StoreObjectId.FromHexEntryId(parameters);

            if (!storeObjectId.IsFolderId)
            {
                throw new ArgumentException(string.Format("id {0} isn't the id of a folder", parameters));
            }
            return(storeObjectId);
        }
        private void ValidateAndUpdateMailPublicFolderParameters()
        {
            if (this.MailRecipientGuid == null && this.MailEnabled == null)
            {
                return;
            }
            Guid?mailRecipientGuid = this.MailRecipientGuid;
            Guid?guid = (mailRecipientGuid != null) ? new Guid?(mailRecipientGuid.GetValueOrDefault()) : this.DataObject.MailRecipientGuid;
            bool flag = this.MailEnabled ?? this.DataObject.MailEnabled;

            if (this.MailRecipientGuid != null && !flag)
            {
                base.WriteError(new ArgumentException(Strings.ErrorSetPublicFolderMailMailEnabledFalse), ErrorCategory.InvalidArgument, this.Identity);
            }
            if (this.MailEnabled != null && this.MailEnabled.Value && guid == null)
            {
                base.WriteError(new ArgumentException(Strings.ErrorSetPublicFolderMailMailRecipientGuidNull), ErrorCategory.InvalidArgument, this.Identity);
            }
            if (this.MailEnabled != null && !this.MailEnabled.Value)
            {
                this.DataObject.MailEnabled = false;
                this.DataObject.ProxyGuid   = null;
                return;
            }
            if (this.MailRecipientGuid != null || (this.MailEnabled != null && this.MailEnabled.Value))
            {
                ADObjectId     identity       = new ADObjectId(guid.Value);
                ADPublicFolder adpublicFolder = this.RecipientSession.Read <ADPublicFolder>(identity) as ADPublicFolder;
                if (adpublicFolder == null)
                {
                    base.WriteError(new ObjectNotFoundException(Strings.ErrorSetPublicFolderMailRecipientGuidNotFoundInAd(guid.Value.ToString())), ErrorCategory.InvalidData, this.Identity);
                }
                StoreObjectId storeObjectId  = StoreObjectId.FromHexEntryId(adpublicFolder.EntryId);
                StoreObjectId storeObjectId2 = StoreObjectId.FromHexEntryId(this.DataObject.EntryId);
                if (!ArrayComparer <byte> .Comparer.Equals(storeObjectId.LongTermFolderId, storeObjectId2.LongTermFolderId))
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorSetPublicFolderMailRecipientGuidLongTermIdNotMatch(adpublicFolder.Id.ToString())), ErrorCategory.InvalidData, this.Identity);
                }
                if (this.DataObject.MailRecipientGuid == null || this.DataObject.MailRecipientGuid.Value != guid.Value)
                {
                    this.DataObject.MailRecipientGuid = new Guid?(guid.Value);
                }
                if (!this.DataObject.MailEnabled)
                {
                    this.DataObject.MailEnabled = true;
                }
            }
        }
        public IEnumerable <SearchSource> Convert(ISearchPolicy policy, IEnumerable <SearchSource> sources)
        {
            Recorder.Trace(5L, TraceType.InfoTrace, "PublicFolderSourceConverter.Convert Sources:", sources);
            IConfigurationSession configurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, policy.RecipientSession.SessionSettings, 46, "Convert", "f:\\15.00.1497\\sources\\dev\\EDiscovery\\src\\MailboxSearch\\WebService\\External\\PublicFolderSourceConverter.cs");

            using (PublicFolderDataProvider provider = new PublicFolderDataProvider(configurationSession, "Get-PublicFolder", Guid.Empty))
            {
                foreach (SearchSource source in sources)
                {
                    if (source.SourceType == SourceType.PublicFolder)
                    {
                        Recorder.Trace(5L, TraceType.InfoTrace, new object[]
                        {
                            "PublicFolderSourceConverter.Convert Source:",
                            source.ReferenceId,
                            "PublicFolderSourceConverter.Type:",
                            source.SourceType
                        });
                        PublicFolder publicFolder = null;
                        try
                        {
                            PublicFolderId publicFolderId2;
                            if (this.IsPath(source.ReferenceId))
                            {
                                Recorder.Trace(5L, TraceType.InfoTrace, "PublicFolderSourceConverter.Convert From Path:", source.ReferenceId);
                                publicFolderId2 = new PublicFolderId(new MapiFolderPath(source.ReferenceId));
                            }
                            else
                            {
                                Recorder.Trace(5L, TraceType.InfoTrace, "PublicFolderSourceConverter.Convert From StoreId:", source.ReferenceId);
                                StoreObjectId storeObjectId = StoreObjectId.FromHexEntryId(source.ReferenceId);
                                publicFolderId2 = new PublicFolderId(storeObjectId);
                            }
                            if (publicFolderId2 != null)
                            {
                                Recorder.Trace(5L, TraceType.InfoTrace, "PublicFolderSourceConverter.Convert PublicFolderId:", publicFolderId2);
                                publicFolder = (PublicFolder)provider.Read <PublicFolder>(publicFolderId2);
                            }
                        }
                        catch (FormatException)
                        {
                            Recorder.Trace(5L, TraceType.InfoTrace, "PublicFolderSourceConverter.Convert FormatException, Source:", source);
                        }
                        if (publicFolder != null)
                        {
                            yield return(this.GetSource(source, publicFolder));
                        }
                        else
                        {
                            Recorder.Trace(5L, TraceType.InfoTrace, "PublicFolderSourceConverter.Convert Failed, Source:", source);
                            yield return(source);
                        }
                    }
                    else if (source.SourceType == SourceType.AllPublicFolders)
                    {
                        Recorder.Trace(5L, TraceType.InfoTrace, new object[]
                        {
                            "PublicFolderSourceConverter.Convert Source:",
                            source.ReferenceId,
                            "Type:",
                            source.SourceType
                        });
                        PublicFolderId             publicFolderId = new PublicFolderId(MapiFolderPath.IpmSubtreeRoot);
                        IEnumerable <PublicFolder> folders        = provider.FindPaged <PublicFolder>(null, publicFolderId, true, null, 50);
                        foreach (PublicFolder publicFolder2 in folders)
                        {
                            if (publicFolder2.FolderPath != MapiFolderPath.IpmSubtreeRoot)
                            {
                                yield return(this.GetSource(source, publicFolder2));
                            }
                        }
                    }
                }
            }
            yield break;
        }
Example #6
0
        // Token: 0x06000B23 RID: 2851 RVA: 0x00023C30 File Offset: 0x00021E30
        internal PublicFolderIdParameter(string publicFolderIdString, bool isEntryId)
        {
            if (string.IsNullOrEmpty(publicFolderIdString))
            {
                throw new ArgumentNullException("publicFolderIdString");
            }
            this.rawIdentity = publicFolderIdString;
            PublicFolderId publicFolderId = null;

            try
            {
                int num = publicFolderIdString.IndexOf('\\');
                if (num < 0)
                {
                    if (isEntryId)
                    {
                        publicFolderId = new PublicFolderId(StoreObjectId.FromHexEntryId(publicFolderIdString));
                    }
                }
                else if (num == 0)
                {
                    if (publicFolderIdString.Length > 1 && publicFolderIdString[num + 1] == '\\')
                    {
                        throw new FormatException(Strings.ErrorIncompletePublicFolderIdParameter(publicFolderIdString));
                    }
                    publicFolderId = new PublicFolderId(MapiFolderPath.Parse(publicFolderIdString));
                }
                else
                {
                    if (!MapiTaskHelper.IsDatacenter)
                    {
                        throw new FormatException(Strings.ErrorIncompletePublicFolderIdParameter(publicFolderIdString));
                    }
                    if (num == publicFolderIdString.Length - 1)
                    {
                        throw new FormatException(Strings.ErrorIncompleteDCPublicFolderIdParameter(publicFolderIdString));
                    }
                    this.Organization = new OrganizationIdParameter(publicFolderIdString.Substring(0, num));
                    if (publicFolderIdString[num + 1] == '\\')
                    {
                        publicFolderId = new PublicFolderId(MapiFolderPath.Parse(publicFolderIdString.Substring(num + 1)));
                    }
                    else if (isEntryId)
                    {
                        publicFolderId = new PublicFolderId(StoreObjectId.FromHexEntryId(publicFolderIdString.Substring(num + 1)));
                    }
                }
            }
            catch (FormatException innerException)
            {
                throw new FormatException(MapiTaskHelper.IsDatacenter ? Strings.ErrorIncompleteDCPublicFolderIdParameter(this.rawIdentity) : Strings.ErrorIncompletePublicFolderIdParameter(this.rawIdentity), innerException);
            }
            catch (CorruptDataException innerException2)
            {
                throw new FormatException(MapiTaskHelper.IsDatacenter ? Strings.ErrorIncompleteDCPublicFolderIdParameter(this.rawIdentity) : Strings.ErrorIncompletePublicFolderIdParameter(this.rawIdentity), innerException2);
            }
            if (publicFolderId != null)
            {
                ((IIdentityParameter)this).Initialize(publicFolderId);
            }
        }