Exemple #1
0
        protected override PublishingSubscriptionData CreateDataObjectFromItem(object[] properties)
        {
            VersionedId versionedId = SharingItemManagerBase <PublishingSubscriptionData> .TryGetPropertyRef <VersionedId>(properties, 1);

            if (versionedId == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal>((long)this.GetHashCode(), "{0}: subscription is missing ID", base.MailboxSession.MailboxOwner);
                return(null);
            }
            string text = SharingItemManagerBase <PublishingSubscriptionData> .TryGetPropertyRef <string>(properties, 4);

            if (string.IsNullOrEmpty(text))
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: subscription {1} is missing ExternalSharingDataType", base.MailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            string text2 = SharingItemManagerBase <PublishingSubscriptionData> .TryGetPropertyRef <string>(properties, 5);

            if (string.IsNullOrEmpty(text2))
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: subscription {1} is missing ExternalSharingUrl", base.MailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            if (!Uri.IsWellFormedUriString(text2, UriKind.Absolute))
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId, string>((long)this.GetHashCode(), "{0}: subscription {1} has invalid ExternalSharingUrl: {2}", base.MailboxSession.MailboxOwner, versionedId, text2);
                return(null);
            }
            string text3 = SharingItemManagerBase <PublishingSubscriptionData> .TryGetPropertyRef <string>(properties, 6);

            if (string.IsNullOrEmpty(text3))
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: subscription {1} is missing ExternalSharingRemoteFolderName", base.MailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            byte[] array = SharingItemManagerBase <PublishingSubscriptionData> .TryGetPropertyRef <byte[]>(properties, 2);

            if (array == null || array.Length == 0)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: subscription {1} is missing ExternalSharingLocalFolderId", base.MailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            return(new PublishingSubscriptionData(versionedId, text, new Uri(text2), text3, StoreObjectId.Deserialize(array)));
        }
Exemple #2
0
        private object[][] FindAll()
        {
            List <object[]> list = new List <object[]>();

            using (QueryResult queryResult = this.folder.ItemQuery(ItemQueryType.None, null, SharingSubscriptionManagerBase <TKey, TData> .ItemQuerySorts, this.itemProperties))
            {
                if (queryResult.SeekToCondition(SeekReference.OriginBeginning, this.itemClassFilter))
                {
                    object[][] rows;
                    int        num;
                    for (;;)
                    {
                        rows = queryResult.GetRows(10000);
                        if (rows.Length == 0)
                        {
                            goto IL_A2;
                        }
                        num = 0;
                        foreach (object[] properties in rows)
                        {
                            string y = SharingItemManagerBase <TData> .TryGetPropertyRef <string>(properties, 0);

                            if (!StringComparer.OrdinalIgnoreCase.Equals(this.itemClass, y))
                            {
                                break;
                            }
                            num++;
                        }
                        if (num != rows.Length)
                        {
                            break;
                        }
                        list.AddRange(rows);
                    }
                    if (num > 0)
                    {
                        Array.Resize <object[]>(ref rows, num);
                        list.AddRange(rows);
                    }
                }
                IL_A2 :;
            }
            return(list.ToArray());
        }
Exemple #3
0
        protected object[] FindFirst(Predicate <object[]> match)
        {
            using (QueryResult queryResult = this.folder.ItemQuery(ItemQueryType.None, null, SharingSubscriptionManagerBase <TKey, TData> .ItemQuerySorts, this.itemProperties))
            {
                if (queryResult.SeekToCondition(SeekReference.OriginBeginning, this.itemClassFilter))
                {
                    for (;;)
                    {
                        object[][] rows = queryResult.GetRows(10000);
                        if (rows.Length == 0)
                        {
                            goto IL_89;
                        }
                        bool flag = false;
                        foreach (object[] array2 in rows)
                        {
                            string y = SharingItemManagerBase <TData> .TryGetPropertyRef <string>(array2, 0);

                            if (!StringComparer.OrdinalIgnoreCase.Equals(this.itemClass, y))
                            {
                                flag = true;
                                break;
                            }
                            if (match(array2))
                            {
                                goto Block_5;
                            }
                        }
                        if (flag)
                        {
                            goto IL_89;
                        }
                    }
Block_5:
                    object[] array2;
                    return(array2);
                }
                IL_89 :;
            }
            return(null);
        }
Exemple #4
0
        private object[] GetRawBindingQueryInFolder(StoreId folderId)
        {
            using (Folder folder = Folder.Bind(this.mailboxSession, folderId))
            {
                using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.Associated, null, null, SharingBindingManager.QueryBindingColumns))
                {
                    if (queryResult.SeekToCondition(SeekReference.OriginBeginning, SharingBindingManager.SharingProviderGuidFilter))
                    {
                        object[][] rows = queryResult.GetRows(2);
                        if (rows.Length > 0)
                        {
                            if (rows.Length > 1)
                            {
                                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, StoreId>((long)this.GetHashCode(), "{0}: There should be only one external sharing binding message associated with a folder, but more than one were found in folder: {1}", this.mailboxSession.MailboxOwner, folderId);
                            }
                            else
                            {
                                object[] array = rows[0];
                                string   x     = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(array, 2);

                                if (StringComparer.OrdinalIgnoreCase.Equals(x, "IPM.Sharing.Binding.In"))
                                {
                                    return(array);
                                }
                            }
                        }
                        else
                        {
                            ExTraceGlobals.SharingTracer.TraceDebug((long)this.GetHashCode(), "The total Items length retrieved from the Query is not greater than zero");
                        }
                    }
                    else
                    {
                        ExTraceGlobals.SharingTracer.TraceDebug <SeekReference, ComparisonFilter>((long)this.GetHashCode(), "Query.SeekToCondition returned false for SeekReference.ForwardFromBeginning {0} and SharingProviderGuidFilter {1}", SeekReference.OriginBeginning, SharingBindingManager.SharingProviderGuidFilter);
                    }
                }
            }
            return(null);
        }
Exemple #5
0
        protected override SharingBindingData CreateDataObjectFromItem(object[] properties)
        {
            VersionedId versionedId = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <VersionedId>(properties, 1);

            if (versionedId == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal>((long)this.GetHashCode(), "{0}: Binding is missing ID", this.mailboxSession.MailboxOwner);
                return(null);
            }
            string text = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(properties, 12);

            if (text == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing sharingLocalType", this.mailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            SharingDataType sharingDataType = SharingDataType.FromContainerClass(text);

            if (sharingDataType == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId, string>((long)this.GetHashCode(), "{0}: Binding {1} has invalid sharingLocalType: {2}", this.mailboxSession.MailboxOwner, versionedId, text);
                return(null);
            }
            string text2 = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(properties, 8);

            if (text2 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing initiatorName", this.mailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            string text3 = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(properties, 9);

            if (text3 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing initiatorSmtpAddress", this.mailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            string text4 = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(properties, 7);

            if (text4 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing remoteFolderName", this.mailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            string text5 = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(properties, 18);

            if (text5 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing remoteFolderId", this.mailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            string text6 = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(properties, 10);

            if (text6 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing localFolderName", this.mailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            string text7 = SharingItemManagerBase <SharingBindingData> .TryGetPropertyRef <string>(properties, 11);

            if (text7 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing localFolderUid", this.mailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            StoreObjectId localFolderId;

            try
            {
                localFolderId = StoreObjectId.FromHexEntryId(text7, sharingDataType.StoreObjectType);
            }
            catch (CorruptDataException)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} has invalid localFolderUid", this.mailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            int?num = SharingItemManagerBase <SharingBindingData> .TryGetPropertyVal <int>(properties, 3);

            if (num == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing flavor", this.mailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            bool       isDefaultFolderShared = 0 != (num.Value & 131072);
            DateTime?  lastSyncTimeUtc       = null;
            ExDateTime?exDateTime            = SharingItemManagerBase <SharingBindingData> .TryGetPropertyVal <ExDateTime>(properties, 15);

            if (exDateTime == null)
            {
                ExTraceGlobals.SharingTracer.TraceDebug <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Binding {1} is missing lastSyncTime", this.mailboxSession.MailboxOwner, versionedId);
            }
            else
            {
                lastSyncTimeUtc = new DateTime?((DateTime)exDateTime.Value.ToUtc());
            }
            return(new SharingBindingData(versionedId, sharingDataType, text2, text3, text4, text5, text6, localFolderId, isDefaultFolderShared, lastSyncTimeUtc));
        }
Exemple #6
0
 protected override object[] FindFirstByKey(PublishingSubscriptionKey subscriptionKey)
 {
     return(base.FindFirst((object[] properties) => StringComparer.OrdinalIgnoreCase.Equals(SharingItemManagerBase <PublishingSubscriptionData> .TryGetPropertyRef <string>(properties, 5), HttpUtility.UrlPathEncode(subscriptionKey.PublishingUrl.ToString()))));
 }
        protected override SharingSubscriptionData CreateDataObjectFromItem(object[] properties)
        {
            VersionedId versionedId = SharingItemManagerBase <SharingSubscriptionData> .TryGetPropertyRef <VersionedId>(properties, 1);

            if (versionedId == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal>((long)this.GetHashCode(), "{0}: subscription is missing ID", base.MailboxSession.MailboxOwner);
                return(null);
            }
            string text = SharingItemManagerBase <SharingSubscriptionData> .TryGetPropertyRef <string>(properties, 4);

            if (string.IsNullOrEmpty(text))
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: subscription {1} is missing ExternalSharingDataType", base.MailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            string text2 = SharingItemManagerBase <SharingSubscriptionData> .TryGetPropertyRef <string>(properties, 5);

            if (string.IsNullOrEmpty(text2))
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: subscription {1} is missing ExternalSharingSharerIdentity", base.MailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            string text3 = SharingItemManagerBase <SharingSubscriptionData> .TryGetPropertyRef <string>(properties, 6);

            if (string.IsNullOrEmpty(text3))
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: subscription {1} is missing ExternalSharingSharerName", base.MailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            string text4 = SharingItemManagerBase <SharingSubscriptionData> .TryGetPropertyRef <string>(properties, 7);

            if (string.IsNullOrEmpty(text4))
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: subscription {1} is missing ExternalSharingRemoteFolderId", base.MailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            string text5 = SharingItemManagerBase <SharingSubscriptionData> .TryGetPropertyRef <string>(properties, 8);

            if (string.IsNullOrEmpty(text5))
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: subscription {1} is missing ExternalSharingRemoteFolderName", base.MailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            bool?flag = SharingItemManagerBase <SharingSubscriptionData> .TryGetPropertyVal <bool>(properties, 9);

            if (flag == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: subscription {1} is missing ExternalSharingIsPrimary", base.MailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            bool   value = flag.Value;
            string text6 = SharingItemManagerBase <SharingSubscriptionData> .TryGetPropertyRef <string>(properties, 10);

            if (string.IsNullOrEmpty(text6))
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: subscription {1} is missing ExternalSharingSharerIdentityFederationUri", base.MailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            if (!Uri.IsWellFormedUriString(text6, UriKind.Absolute))
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId, string>((long)this.GetHashCode(), "{0}: subscription {1} has invalid ExternalSharingSharerIdentityFederationUri: {2}", base.MailboxSession.MailboxOwner, versionedId, text6);
                return(null);
            }
            string text7 = SharingItemManagerBase <SharingSubscriptionData> .TryGetPropertyRef <string>(properties, 11);

            if (string.IsNullOrEmpty(text7))
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: subscription {1} is missing ExternalSharingUrl", base.MailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            if (!Uri.IsWellFormedUriString(text7, UriKind.Absolute))
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId, string>((long)this.GetHashCode(), "{0}: subscription {1} has invalid ExternalSharingUrl: {2}", base.MailboxSession.MailboxOwner, versionedId, text7);
                return(null);
            }
            byte[] array = SharingItemManagerBase <SharingSubscriptionData> .TryGetPropertyRef <byte[]>(properties, 2);

            if (array == null || array.Length == 0)
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: subscription {1} is missing ExternalSharingLocalFolderId", base.MailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            string text8 = SharingItemManagerBase <SharingSubscriptionData> .TryGetPropertyRef <string>(properties, 12);

            if (string.IsNullOrEmpty(text8))
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: subscription {1} is missing ExternalSharingSharingKey", base.MailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            string text9 = SharingItemManagerBase <SharingSubscriptionData> .TryGetPropertyRef <string>(properties, 13);

            if (string.IsNullOrEmpty(text9))
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: subscription {1} is missing ExternalSharingSubscriberIdentity", base.MailboxSession.MailboxOwner, versionedId);
                return(null);
            }
            return(new SharingSubscriptionData(versionedId, text, text2, text3, text4, text5, value, new Uri(text6), new Uri(text7), StoreObjectId.Deserialize(array), text8, text9));
        }
        protected override object[] FindFirstByKey(SharingSubscriptionKey subscriptionKey)
        {
            string sharerIdentity = subscriptionKey.SharerIdentity;
            string remoteFolderId = subscriptionKey.RemoteFolderId;

            return(base.FindFirst((object[] properties) => StringComparer.OrdinalIgnoreCase.Equals(sharerIdentity, SharingItemManagerBase <SharingSubscriptionData> .TryGetPropertyRef <string>(properties, 5)) && StringComparer.OrdinalIgnoreCase.Equals(remoteFolderId, SharingItemManagerBase <SharingSubscriptionData> .TryGetPropertyRef <string>(properties, 7))));
        }
 private object[] FindPrimaryByDataType(string dataType, string sharerIdentity)
 {
     return(base.FindFirst((object[] properties) => StringComparer.OrdinalIgnoreCase.Equals(dataType, SharingItemManagerBase <SharingSubscriptionData> .TryGetPropertyRef <string>(properties, 4)) && StringComparer.OrdinalIgnoreCase.Equals(sharerIdentity, SharingItemManagerBase <SharingSubscriptionData> .TryGetPropertyRef <string>(properties, 5)) && SharingItemManagerBase <SharingSubscriptionData> .TryGetPropertyVal <bool>(properties, 9) == true));
 }
Exemple #10
0
 public TData GetByLocalFolderId(StoreObjectId localFolderId)
 {
     this.CheckDisposed("GetByLocalFolderId");
     Util.ThrowOnNullArgument(localFolderId, "localFolderId");
     ExTraceGlobals.SharingTracer.TraceDebug <IExchangePrincipal, StoreObjectId>((long)this.GetHashCode(), "{0}: looking for subscription by folderId: {1}", this.mailboxSession.MailboxOwner, localFolderId);
     byte[]   localFolderIdBytes = localFolderId.GetBytes();
     object[] array = this.FindFirst((object[] properties) => ArrayComparer <byte> .Comparer.Equals(localFolderIdBytes, SharingItemManagerBase <TData> .TryGetPropertyRef <byte[]>(properties, 2)));
     if (array != null)
     {
         TData tdata = this.CreateDataObjectFromItem(array);
         ExTraceGlobals.SharingTracer.TraceDebug <IExchangePrincipal, TData>((long)this.GetHashCode(), "{0}: found subscription {1}", this.mailboxSession.MailboxOwner, tdata);
         return(tdata);
     }
     ExTraceGlobals.SharingTracer.TraceDebug <IExchangePrincipal, StoreObjectId>((long)this.GetHashCode(), "{0}: No subscription was found for folder: {1}.", this.mailboxSession.MailboxOwner, localFolderId);
     return(default(TData));
 }