示例#1
0
        public static string DiscoverEwsUrl(IExchangePrincipal mailbox)
        {
            Uri uri;

            if (!EwsHelper.IsDatacenter)
            {
                EwsHelper.Tracer.TraceDebug(0L, "Not running in DC. Will use ServiceTopology to discover the url");
                ServerVersion mailboxVersion = new ServerVersion(mailbox.MailboxInfo.Location.ServerVersion);
                IList <WebServicesService> list;
                try
                {
                    ClientAccessType clientAccessType = EwsHelper.ClientAccessType;
                    EwsHelper.Tracer.TraceDebug <ClientAccessType>(0L, "Will try to discover the URL for EWS with the following client access type: {0}", clientAccessType);
                    ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Management\\EwsDriver\\EwsHelper.cs", "DiscoverEwsUrl", 119);
                    list = currentServiceTopology.FindAll <WebServicesService>(mailbox, clientAccessType, delegate(WebServicesService service)
                    {
                        ServerVersion serverVersion = new ServerVersion(service.ServerVersionNumber);
                        return(mailboxVersion.Major == serverVersion.Major && mailboxVersion.Minor <= serverVersion.Minor && !service.IsOutOfService);
                    }, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Management\\EwsDriver\\EwsHelper.cs", "DiscoverEwsUrl", 121);
                }
                catch (LocalizedException arg)
                {
                    EwsHelper.Tracer.TraceError <IExchangePrincipal, LocalizedException>(0L, "Unable to discover internal URL for EWS for mailbox {0} due exception {1}", mailbox, arg);
                    return(null);
                }
                if (list.Count == 0)
                {
                    EwsHelper.Tracer.TraceError <IExchangePrincipal>(0L, "Unable to find internal URL for EWS for mailbox {0}", mailbox);
                    return(null);
                }
                WebServicesService webServicesService;
                if ((webServicesService = list.FirstOrDefault((WebServicesService service) => string.Equals(service.ServerFullyQualifiedDomainName, mailbox.MailboxInfo.Location.ServerFqdn, StringComparison.OrdinalIgnoreCase) && service.Url != null)) == null && (webServicesService = list.FirstOrDefault(delegate(WebServicesService service)
                {
                    ServerVersion serverVersion = new ServerVersion(service.ServerVersionNumber);
                    return(service.Url != null && mailboxVersion.Major == serverVersion.Major && mailboxVersion.Minor == serverVersion.Minor);
                })) == null)
                {
                    webServicesService = list.FirstOrDefault((WebServicesService service) => service.Url != null);
                }
                WebServicesService webServicesService2 = webServicesService;
                uri = ((webServicesService2 == null) ? null : webServicesService2.Url);
                goto IL_1EA;
            }
            EwsHelper.Tracer.TraceDebug(0L, "Running in DC. Will use BackEndLocator to discover the url");
            if (EwsHelper.discoveryEwsInternalUrl == null)
            {
                EwsHelper.discoveryEwsInternalUrl = (Func <IMailboxInfo, Uri>)Delegate.CreateDelegate(typeof(Func <IMailboxInfo, Uri>), Type.GetType("Microsoft.Exchange.Data.ApplicationLogic.Cafe.BackEndLocator, Microsoft.Exchange.Data.ApplicationLogic").GetMethod("GetBackEndWebServicesUrl", BindingFlags.Static | BindingFlags.Public, null, new Type[]
                {
                    typeof(IMailboxInfo)
                }, null));
            }
            uri = EwsHelper.discoveryEwsInternalUrl(mailbox.MailboxInfo);
IL_1EA:
            if (!(uri == null))
            {
                return(uri.ToString());
            }
            return(null);
        }
示例#2
0
 public static SerializedSecurityContextType CreateSerializedSecurityContext(IExchangePrincipal mailbox, SecurityAccessToken securityAccessToken)
 {
     return(new SerializedSecurityContextType
     {
         UserSid = securityAccessToken.UserSid,
         GroupSids = EwsHelper.SidStringAndAttributesConverter(securityAccessToken.GroupSids),
         RestrictedGroupSids = EwsHelper.SidStringAndAttributesConverter(securityAccessToken.RestrictedGroupSids),
         PrimarySmtpAddress = mailbox.MailboxInfo.PrimarySmtpAddress.ToString()
     });
 }
示例#3
0
        public static string DiscoverExternalEwsUrl(ExchangePrincipal mailbox)
        {
            if (EwsHelper.discoveryEwsExternalUrl == null)
            {
                EwsHelper.discoveryEwsExternalUrl = (Func <IExchangePrincipal, Uri>)Delegate.CreateDelegate(typeof(Func <IExchangePrincipal, Uri>), Type.GetType("Microsoft.Exchange.Data.ApplicationLogic.Cafe.FrontEndLocator, Microsoft.Exchange.Data.ApplicationLogic").GetMethod("GetFrontEndWebServicesUrl", BindingFlags.Static | BindingFlags.Public, null, new Type[]
                {
                    typeof(IExchangePrincipal)
                }, null));
            }
            Uri uri = EwsHelper.discoveryEwsExternalUrl(mailbox);

            if (!(uri == null))
            {
                return(uri.ToString());
            }
            return(null);
        }
        private void OnSerializeCustomSoapHeaders(XmlWriter writer)
        {
            object obj = null;

            if (this.logonType != null)
            {
                obj = EwsHelper.CreateSpecialLogonAuthenticationHeader(this.Mailbox, this.logonType.Value, this.budgetType, this.RequiredServerVersion);
            }
            else if (this.securityAccessToken != null)
            {
                obj = EwsHelper.CreateSerializedSecurityContext(this.Mailbox, this.securityAccessToken);
            }
            if (obj != null)
            {
                SafeXmlSerializer safeXmlSerializer = new SafeXmlSerializer(obj.GetType());
                safeXmlSerializer.Serialize(writer, obj);
            }
        }
示例#5
0
 public EwsStoreObjectPropertyDefinition(string name, ExchangeObjectVersion versionAdded, Type type, PropertyDefinitionFlags flags, object defaultValue, object initialValue, PropertyDefinitionBase storePropertyDefinition, Action <Item, object> itemPropertySetter) : base(name, versionAdded ?? EwsHelper.EwsVersionToExchangeObjectVersion(storePropertyDefinition.Version), type, flags, defaultValue, initialValue)
 {
     if (storePropertyDefinition == null)
     {
         throw new ArgumentNullException("storePropertyDefinition");
     }
     if (storePropertyDefinition is PropertyDefinition)
     {
         if (itemPropertySetter == null && !this.IsReadOnly && storePropertyDefinition != ItemSchema.Attachments)
         {
             throw new ArgumentException("ItemPropertySetter must be provided for writable first class property.");
         }
     }
     else if (storePropertyDefinition is ExtendedPropertyDefinition && itemPropertySetter != null)
     {
         throw new ArgumentException("ItemPropertySetter shouldn't be provided for extended property.");
     }
     this.storePropertyDefinition = storePropertyDefinition;
     this.ItemPropertySetter      = itemPropertySetter;
 }