예제 #1
0
        internal SharingContext(Folder folderToShare, SharingProvider sharingProvider) : this()
        {
            Util.ThrowOnNullArgument(folderToShare, "folderToShare");
            MailboxSession     mailboxSession = folderToShare.Session as MailboxSession;
            IExchangePrincipal mailboxOwner   = mailboxSession.MailboxOwner;

            if (sharingProvider == null)
            {
                SharingProvider[] compatibleProviders = SharingProvider.GetCompatibleProviders(folderToShare);
                if (compatibleProviders.Length == 0)
                {
                    ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Cannot share folder {1}: no compatible provider was found.", mailboxOwner, folderToShare.Id);
                    throw new CannotShareFolderException(ServerStrings.NoProviderSupportShareFolder);
                }
                for (int i = 0; i < compatibleProviders.Length; i++)
                {
                    ExTraceGlobals.SharingTracer.TraceDebug <IExchangePrincipal, SharingProvider, VersionedId>((long)this.GetHashCode(), "{0}: Find compatible provider {1} for folder {2}.", mailboxOwner, compatibleProviders[i], folderToShare.Id);
                    this.AvailableSharingProviders.Add(compatibleProviders[i], null);
                }
            }
            else if (!sharingProvider.IsCompatible(folderToShare))
            {
                ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId, SharingProvider>((long)this.GetHashCode(), "{0}: Cannot share folder {1} with sharing provider: {2}.", mailboxOwner, folderToShare.Id, sharingProvider);
                if (sharingProvider == SharingProvider.SharingProviderPublish)
                {
                    throw new FolderNotPublishedException();
                }
                throw new CannotShareFolderException(ServerStrings.NoProviderSupportShareFolder);
            }
            else
            {
                this.AvailableSharingProviders.Add(sharingProvider, null);
                if (sharingProvider == SharingProvider.SharingProviderPublish)
                {
                    this.PopulateUrls(folderToShare);
                }
            }
            this.InitiatorName        = mailboxOwner.MailboxInfo.DisplayName;
            this.InitiatorSmtpAddress = mailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString();
            this.InitiatorEntryId     = AddressBookEntryId.MakeAddressBookEntryID(mailboxOwner);
            this.FolderClass          = folderToShare.ClassName;
            this.FolderId             = folderToShare.StoreObjectId;
            this.IsPrimary            = (mailboxSession.IsDefaultFolderType(this.FolderId) != DefaultFolderType.None);
            this.FolderName           = (this.IsPrimary ? this.DataType.DisplayName.ToString(mailboxSession.InternalPreferedCulture) : folderToShare.DisplayName);
            this.MailboxId            = StoreEntryId.ToProviderStoreEntryId(mailboxOwner);
            this.SharingMessageType   = SharingMessageType.Invitation;
            this.SharingPermissions   = SharingContextPermissions.Reviewer;
            if (StringComparer.OrdinalIgnoreCase.Equals(folderToShare.ClassName, "IPF.Appointment"))
            {
                this.SharingDetail = (this.IsPrimary ? SharingContextDetailLevel.AvailabilityOnly : SharingContextDetailLevel.FullDetails);
            }
            this.SetDefaultCapabilities();
            this.UserLegacyDN = mailboxOwner.LegacyDn;
        }
예제 #2
0
        public static byte[] ToProviderStoreEntryId(IExchangePrincipal exchangePrincipal, bool isPublicStore)
        {
            Util.ThrowOnNullArgument(exchangePrincipal, "exchangePrincipal");
            if (exchangePrincipal.MailboxInfo.IsRemote)
            {
                throw new ArgumentException("This method should not be used to remote connections.");
            }
            string mailboxLegacyDn   = exchangePrincipal.MailboxInfo.GetMailboxLegacyDn(exchangePrincipal.LegacyDn);
            string serverFqdn        = exchangePrincipal.MailboxInfo.Location.ServerFqdn;
            int    num               = serverFqdn.IndexOf(".", StringComparison.Ordinal);
            string serverNetBiosName = (num != -1) ? serverFqdn.Substring(0, num) : serverFqdn;

            return(StoreEntryId.ToProviderStoreEntryId(serverNetBiosName, mailboxLegacyDn, isPublicStore));
        }
예제 #3
0
 public static byte[] ToProviderStoreEntryId(IExchangePrincipal exchangePrincipal)
 {
     return(StoreEntryId.ToProviderStoreEntryId(exchangePrincipal, false));
 }