/// <summary>
 /// Initializes a new instance of the <see cref="PrivilegedUserId"/> class.
 /// </summary>
 /// <param name="openType">The open type.</param>
 /// <param name="idType">The type of this Id.</param>
 /// <param name="id">The user Id.</param>
 public PrivilegedUserId(PrivilegedLogonType openType, ConnectingIdType idType, string id)
     : this()
 {
     this.logonType = openType;
     this.idType = idType;
     this.id = id;
 }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PrivilegedUserId"/> class.
 /// </summary>
 /// <param name="openType">The open type.</param>
 /// <param name="idType">The type of this Id.</param>
 /// <param name="id">The user Id.</param>
 PrivilegedUserId(PrivilegedLogonType openType, ConnectingIdType idType, String id)
     : this()
 {
     this.logonType = openType;
     this.idType    = idType;
     this.id        = id;
 }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="connectingIdType"></param>
        /// <param name="roomAddress"></param>
        /// <param name="itemId"></param>
        /// <param name="filterPropertySet"></param>
        /// <returns></returns>
        public AppointmentObjectId GetAppointment(ConnectingIdType connectingIdType, string roomAddress, ItemId itemId, IList <PropertyDefinitionBase> filterPropertySet)
        {
            SetImpersonation(connectingIdType, roomAddress);
            var appointmentTime = Appointment.Bind(ExchangeService, itemId, new PropertySet(filterPropertySet));

            PropertySet psPropSet = new PropertySet(BasePropertySet.FirstClassProperties)
            {
                CleanGlobalObjectId
            };

            appointmentTime.Load(psPropSet);
            appointmentTime.TryGetProperty(CleanGlobalObjectId, out object CalIdVal);


            var objectId = new AppointmentObjectId()
            {
                Id             = itemId,
                Item           = appointmentTime,
                Base64UniqueId = Convert.ToBase64String((Byte[])CalIdVal),
                ICalUid        = appointmentTime.ICalUid,
                Organizer      = appointmentTime.Organizer
            };


            return(objectId);
        }
示例#4
0
        /// <summary>
        /// Creates pull subscriptiosn for the specific rooms
        /// </summary>
        /// <param name="timeout">The timeout, in minutes, after which the subscription expires. Timeout must be between 1 and 1440.</param>
        /// <param name="watermark">An optional watermark representing a previously opened subscription.</param>
        /// <returns></returns>
        public PullSubscription CreatePullSubscription(ConnectingIdType connectingIdType, string roomAddress, int timeout = 30, string watermark = null)
        {
            ServicePointManager.DefaultConnectionLimit = ServicePointManager.DefaultPersistentConnectionLimit;

            try
            {
                SetImpersonation(connectingIdType, roomAddress);

                var sub = ExchangeService.SubscribeToPullNotifications(
                    new FolderId[] { WellKnownFolderName.Calendar },
                    timeout,
                    watermark,
                    EventType.Created, EventType.Deleted, EventType.Modified, EventType.Moved, EventType.Copied);

                Trace.WriteLine($"CreatePullSubscription {sub.Id} to room {roomAddress}");
                return(sub);
            }
            catch (Microsoft.Exchange.WebServices.Data.ServiceRequestException srex)
            {
                Trace.WriteLine($"Failed to provision subscription {srex.Message}");
                throw new Exception($"Subscription could not be created for {roomAddress} with MSG:{srex.Message}");
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ImpersonatedUserId"/> class.
 /// </summary>
 /// <param name="idType">The type of this Id.</param>
 /// <param name="id">The user Id.</param>
 ImpersonatedUserId(ConnectingIdType idType, String id)
     : this()
 {
     this.idType = idType;
     this.id     = id;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ImpersonatedUserId"/> class.
 /// </summary>
 /// <param name="idType">The type of this Id.</param>
 /// <param name="id">The user Id.</param>
 public ImpersonatedUserId(ConnectingIdType idType, string id)
     : this()
 {
     this.idType = idType;
     this.id = id;
 }
示例#7
0
        /// <summary>
        /// Get the ExchangeService from a given row.
        /// </summary>
        private ExchangeService LoadExchangeServiceFromProfileRow(
            ServicesProfile.ServiceBindingRow row,
            NetworkCredential cred,
            out EWSEditor.Common.EwsEditorAppSettings oAppSettings)
        {
            // Create the ExchangeService


            if (!row.IsRequestedServerVersionNull())
            {
                // Convert the string to an ExchangeVersion enumeration
                ExchangeVersion req =
                    (ExchangeVersion)System.Enum.Parse(typeof(ExchangeVersion), row.RequestedServerVersion);
                EwsProxyFactory.RequestedExchangeVersion = req;
            }


            // Load autodiscover email if found
            if (!row.IsAutoDiscoverEmailNull())
            {
                EwsProxyFactory.AllowAutodiscoverRedirect = GlobalSettings.AllowAutodiscoverRedirect;
                EwsProxyFactory.ServiceEmailAddress       = new EmailAddress(row.AutoDiscoverEmail);
            }

            if (!row.IsServicesURLNull())
            {
                EwsProxyFactory.EwsUrl = new Uri(row.ServicesURL);
            }


            // If ImpersonationType is specified then we assume an Id is as well
            if (!row.IsImpersonationTypeNull())
            {
                // Convert the string to a ConnectingIdType enumeration
                ConnectingIdType impType =
                    (ConnectingIdType)System.Enum.Parse(typeof(ConnectingIdType), row.ImpersonationType);
                EwsProxyFactory.UserToImpersonate = new ImpersonatedUserId(impType, row.ImpersonationId);
            }

            // If credentials are not required then use DefaultCredentials
            if (row.UsesDefaultCredentials)
            {
                EwsProxyFactory.UseDefaultCredentials = true;
            }
            else
            {
                if (cred != null)
                {
                    EwsProxyFactory.ServiceCredential = cred;
                }
                else
                {
                    throw new ApplicationException("Credentials are required for this binding.");
                }
            }


            ExchangeService oService = EwsProxyFactory.CreateExchangeService();

            oAppSettings = new EWSEditor.Common.EwsEditorAppSettings();
            EwsProxyFactory.SetAppSettingsFromProxyFactory(ref oAppSettings);

            return(oService);
            //return EwsProxyFactory.CreateExchangeService();
        }
示例#8
0
 public void SetImpersonation(ConnectingIdType connectingIdType, string emailAddress)
 {
     ExchangeService.ImpersonatedUserId = new ImpersonatedUserId(connectingIdType, emailAddress);
 }