I am getting the EWS URL as below:
var response = myAutodiscoverService.GetUserSettings(
"userA#domain.com",
UserSettingName.ExternalEwsUrl,
UserSettingName.InternalEwsUrl,
UserSettingName.EwsSupportedSchemas);
string settingValue;
if (response.TryGetSettingValue(UserSettingName.ExternalEwsUrl, out settingValue)
|| response.TryGetSettingValue(UserSettingName.InternalEwsUrl, out settingValue))
{
// If ExternalEwsUrl is not returned in the response,
// we consider InternalEwsUrl for auto-discover
string ewsurl = settingValue;
}
Now, I am caching this ewsurl I get with this request as recommended since auto-discovery is really slow. What happens when this ewsurl expires (because let's say user's mailbox was moved to a different endpoint). What error should I expect in order to implement a failure mechanism to get the new updated ews url?
Edit: I am using the ews url to subscribe for new mail events on EWS using ExchangeService.SubscribeToPushNotifications So I have another question, suppose if the ews url was changed after user subscribed for notifications, will I get a notification for that user for a new mail event on the callback url of my application?
I seem to recall the ROT from MSFT was you should re-autodiscover every 24 hours, but I've not seen anything recently. As to the Push notifications: since there is a "heartbeat" facility in Push notifications, if you miss two heartbeats in a row, it's safe to say you should tear down the subscription and re-subscribe, which to be safe, implies re-autodiscovery. Of course with O365, since the EWS URL seems (for now) to always be the same, re-autodiscovery is less of a concern.
Related
I am using an Onvif-supported camera and am controlling it using onvif wsdl's (specifically ImagingService, Media10, and PTZ). These work great for controlling most aspects of the camera, but there are a few settings that I want to modify that do not seem to be supported by my camera's version of Onvif.
Onvif works by sending soap requests/packets to the camera. However, when I used Wireshark and observed what happens when I use the software the camera came with, I noticed it works by sending http GET/POST requests containing FormUrlEncoded messages, and one of the fields is labelled session, presumably the session ID for the connection. I was able to recreate the message that the camera's software sends, send it, and confirm that my settings change. However, whenever a new session starts (different ID), it no longer works, and my http response contains:
{"error":{"code":287637505,"message":"Invalid session in request data!"},"result":false}
In other words, hard coding the session Id that I got through wireshark was the only way I could get it to work, but as soon as the session changes it no longer works. I was wondering if there was a way to easily get the session ID, store it as a variable, and then just place it within my messages. I would hope this would be possible either through the HttpClient, or any of the three Onvif clients I am using (MediaClient, ImagingClient, or PTZClient).
I have tried searching through many of the methods/fields in each of the clients above, creating HttpWebRequests, looking through the response messages for GET & POST, looking around where the login credentials are kept, and creating a Cookie with the info.
The way I go about setting everything up is rather simple:
private static readonly HttpClient httpClient = new HttpClient();
var msg = $"{{\"method\":\"configManager.setConfig\",\"params\":{{\"name\":\"VideoInExposure\",\"table\":" +
$"[[{{\"AntiFlicker\":2,\"Compensation\":50,\"DoubleExposure\":0,\"Gain\":50,\"GainMax\":2,\"GainMin\":0," +
$"\"GlareInhibition\":0,\"Iris\":50,\"IrisAuto\":true,\"IrisMax\":30,\"IrisMin\":0,\"Mode\":4,\"RecoveryTime\":900," +
$"\"SlowAutoExposure\":50,\"SlowShutter\":false,\"SlowSpeed\":30,\"Speed\":0,\"Value1\":250,\"Value2\":250," +
$"\"WideDynamicRange\":0,\"WideDynamicRangeMode\":0}}}]],\"options\":[]}},\"id\":6123,\"session\":\"4ec9a21aac415eead620ab163141fa03\"}}";
var response = await httpClient.PostAsync("http://192.168.100.233/RPC2", new StringContent(msg, Encoding.UTF8, "application/x-www-form-urlencoded"));
Where the portion labeled session at the end of the message is the string that I need to obtain.
I was hoping this property would be stored somewhere accessible, either in the client, or within a response if I just do a simple GET command, but I have not yet found this to be the case. Any help is greatly appreciated!
edit: I have also tried getting this value from the soap commands that Onvif already uses, with no luck so far. But if there is a way to do it that way I am very open to it.
I have successfully connected to Microsoft Graph using OAuth. I can receive and send emails from my Office365 account.
But I am completely stuck on how to receive emails automatically, similar to the IMAP IDLE routine.
I am referencing
using Microsoft.Graph;
using Microsoft.Toolkit.Services.MicrosoftGraph;
I have tried Subscription but have no clue what to do next, or even if this is correct.
Subscription sub = new Subscription {
ChangeType = "created",
NotificationUrl = "urn:ietf:wg:oauth:2.0:oob",
Resource = "/users/me/messages",
ExpirationDateTime = DateTimeOffset.Now.AddMinutes(20),
ClientState = "????" // if applicable, what is this
};
To make a subscription you need to expose a notification URL with https (see graph documentation).
POST https://graph.microsoft.com/v1.0/subscriptions
Content-Type: application/json
{
"changeType": "created,updated",
"notificationUrl": > "https://webhook.azurewebsites.net/notificationClient",
"resource": "/me/mailfolders('inbox')/messages",
"expirationDateTime": "2016-03-20T11:00:00.0000000Z",
"clientState": "SecretClientState"
}
If you want examples the graph documentation references a Node.js and asp.net example. Both use ngrok to expose an https URL (just for testing purposes though). The program tunnels HTTP requests through to your localhost (like a reverse proxy). If you have that setup, you have to validate your request. When you send your subscription request the first post message your notification URL will receive is a message with a validation token (see doc). You have to send this validation token back. Now you should receive notifications on your specified notification URL.
You can read about the Subscription resource type and its properties in the graph documentation.
For example, the client state is described as:
Specifies the value of the clientState property sent by the service in each notification. The maximum length is 255 characters. The client can check that the notification came from the service by comparing the value of the clientState property sent with the subscription with the value of the clientState property received with each notification.
Subscriptions are not in possible at this moment using Microsoft Graph for UWP, for notifications the Outlook 365 API should be used. The Microsoft graph api can be used for Auth and other tasks though.
Can Microsoft consider including streaming notifications in Microsoft Graph?
I have a WCF Service and and an Website(say www.GoogleNotificationCallback.com) to receive Google Push notification from Google calenders.
Whenever some event is updated/Deleted/Added on Google calendar, it sends back an notification to my Endpoint(www.GoogleNotificationCallback.com)
To manage the load for incoming requests from google calender for push notification, I have load balancing servers on which I have my website(www.GoogleNotificationCallback.com) and WCF service hosted.
Every thing is working fine, but the issue is, if I create/Update/Delete/Move any Event on Google Calendar it sends back multiple hits to the endpoint(www.GoogleNotificationCallback.com).
I checked for ChannelId, MessageId and CalendarId from the current Context.
{var context = HttpContext.Current;
string reqheaders = "reached";
var actualRequest = context.Request;
var reqKeys = context.Request.Headers.AllKeys;}
But for each current context.Request I am getting same CalenderId but different ChannelId and MessageId.
I am not able to understand why Google is creating multiple channels for an single change ? OR why it is giving multiple push notifications to my end point (www.GoogleNotificationCallback.com)?
Is there any settings that i am missing or via coding i am doing any mistake.
can any one please guide me for the same?
I am new to using Sendgrid emails using c# .Net library. Our requirements wants us to track the status of the email like Delivered/Went to Spam/Client opened/reported as spam etc., By looking at the documentations and answers from other users to my previous questions its my understanding that there is no direct way to track the status of the email (like result object).
It would be really helpful if someone can point me to some example/sample codes or documentation/implementation in C# for the following
1) Adding unique parameters while sending the email using send grid API. Can I use a Guid string as my argument
I am assuming what I am doing below is correct.
var myMessage = new SendGridMessage();
var identifiers = new Dictionary<String, String>();
identifiers["Email_ID"] = "Email_ID";
identifiers["Email_Key"] = "9ebccd0d-67c0-4c28-bbf3-83d5bb69f098";
myMessage.AddUniqueArgs(identifiers);
2) How to use event webhooks to get the status with the unique argument that I used above from the http_post so that I can associate an email to the status. Any sample code , documentation in c# or an overall idea of how this works will get me started on this.
Appreciate your time and answers.
Sending emails via SendGrid is easier from C# using the official library that SendGrid provides. From your code example, it looks like you may already be using this - good job.
The unique argument should work as long as its been stringified, and you're not trying to pass an object to myMessage.AddUniqueArgs.
The Event Webhook will send a JSON packet to any URL that you specify. If you have included unique arguments in an email that you send out via SendGrid then these are automatically added to each event response you get back from the webhook - you don't need to turn anything else on to get the arguments as well.
There is an example of this call and the resulting response in the SendGrid Documentation.
SendGrid has an Event Webhook which posts events related to your email
activity to a URL of your choice. This is an easily deployable
solution that allows for customers to easiy get up and running
processing (parse and save) their event webhooks.
This is docker-based solution which can be deployed on cloud services
like Heroku out of the box.
https://github.com/sendgrid/sendgrid-csharp/tree/main/examples/eventwebhook/consumer
I have the following code:
(Meeting beeing the exchange appointment)
For Each Recipient As String In emailAdresses
For i As Integer = 0 To Meeting.RequiredAttendees.Count - 1
If (Meeting.RequiredAttendees(i).Address).ToUpper() = Recipient.ToUpper() Then
Meeting.RequiredAttendees.RemoveAt(i)
Exit For
End If
Next
Next
Meeting.Update(ConflictResolutionMode.AutoResolve, SendInvitationsOrCancellationsMode.SendOnlyToChanged)
Now as you can see i'm using SendInvitationsOrCancellationsMode.SendOnlyToChanged.
But even though that i'm using that mode it is still sending the appointment to all of the attendees.
I've looked at msdn and the code is exactly the same. And msdn tells me the following should happen:
Save the meeting and send a meeting cancellation message to the attendee or attendees that you removed
So basically msdn sais it is works but it does not. Is there a work around for this issue or is anyone else experiencing the same problem?
our exchange server is a 2007 SP1 version.
The answer can be in C# or VB.NET, I'll translate it to the language we need.
PS. Adding members and using this mode causes the invite to send to the newly added member only. But as I said before deleting does not have this same behaviour.
Doing:
Meeting.Update(ConflictResolutionMode.NeverOverwrite, SendInvitationsOrCancellationsMode.SendOnlyToChanged)
Instead of:
Meeting.Update(ConflictResolutionMode.AutoResolve, SendInvitationsOrCancellationsMode.SendOnlyToChanged)
Solved my problem, I do not know why and what it was having trouble with though.
Using ConflictResolutionMode.AutoResolve instead of ConflictResolutionMode.NeverOverwrite did not work for me. After some research, I found out that this is the normal behaviour.
The SendInvitationsOrCancellationsMode enum's values SendOnlyToChanged and SendToChangedAndSaveCopy behave similarly when it comes to sending email (the only difference is that the latter saves a copy of the sent email and the former doesn't):
Send meeting invitations/cancellations only to attendees that have
been added or modified
There is no reference to attendees that have been removed. I thought that the work 'modified' here means that, but apparently that is not the case.
This Microsoft Support Article (Article ID: 2873493) says that this is the expected behaviour:
EWS issue: SentToChangeAndSaveCopy parameter in Appointment.Update
method does not work
Symptoms
Consider the following scenario:
You build an Exchange Web Services (EWS) application to update a meeting request in a Microsoft Exchange Server 2010 environment.
One or more invitees in the meeting request are externals or distribution lists.
You use the Appointment.Update method together with the SentToChangeAndSaveCopy parameter to remove one invitee from the
meeting request and to update the meeting request.
In this scenario, a meeting update is sent to all invitees.
Cause
This behavior is expected.