Push Notifications with specified credentials / as another account

  • Thread starter Massimo Russo
  • Start date Views 1,569
Status
Not open for further replies.
M

Massimo Russo

Hi!

I'm using the Exchange push notifications the first time. I'm trying to push a notification every time a new appointment has created, modified, deleted and so on.

Actually the push works pretty fine, the asmx receives all the calls. For this, I'm using the sample code provided in the Exchange Server 2010 Web Services SDK, I think it's called " PushNotificationSubscriber" :

public static void SubscribeForPushNotifications() { System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate (Object obj, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) { // Replace this line with code to validate server certificate. return true ; }; // Create the bindings and set the credentials. ExchangeServiceBinding esb = new ExchangeServiceBinding(); esb.Url = " https://myexchange2010/EWS/Exchange.asmx" ; esb.Credentials = new NetworkCredential(" user" , " password" , " domain" ); // Create a new subscription. SubscribeType subscribeRequest = new SubscribeType(); PushSubscriptionRequestType pushSubscription = new PushSubscriptionRequestType(); // Subscribe to events in the inbox folder. BaseFolderIdType[] folders = new BaseFolderIdType[1]; DistinguishedFolderIdType folderId = new DistinguishedFolderIdType(); folderId.Id = DistinguishedFolderIdNameType.calendar; folders[0] = folderId; pushSubscription.FolderIds = folders; // Subscribe to all events. NotificationEventTypeType[] eventTypes = new NotificationEventTypeType[6]; eventTypes[0] = NotificationEventTypeType.NewMailEvent; eventTypes[1] = NotificationEventTypeType.CopiedEvent; eventTypes[2] = NotificationEventTypeType.CreatedEvent; eventTypes[3] = NotificationEventTypeType.DeletedEvent; eventTypes[4] = NotificationEventTypeType.ModifiedEvent; eventTypes[5] = NotificationEventTypeType.MovedEvent; pushSubscription.EventTypes = eventTypes; // Receive push notifications every 1 minutes. pushSubscription.StatusFrequency = 1; // Identify the location of the client Web service. pushSubscription.URL = " http://MySharePoint/_vti_bin/PushReceiver.asmx" ; // Form the subscribe request. subscribeRequest.Item = pushSubscription; // Send the subscribe request and get the response. SubscribeResponseType subscribeResponse = esb.Subscribe(subscribeRequest); // Check the result. if (subscribeResponse.ResponseMessages.Items.Length > 0 && subscribeResponse.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Success) { SubscribeResponseMessageType subscribeResponseMessage = subscribeResponse.ResponseMessages.Items[0] as SubscribeResponseMessageType; using (StreamWriter sw = new StreamWriter(" MailboxEventLog.txt" )) { sw.WriteLine(" Subscribed for Push notifications: {0}" , subscribeResponseMessage.SubscriptionId); } } CreateXmlMessageTextFile(subscribeRequest, subscribeResponse); }

My problem now is that the web service, to which the notifications will be pushed, needs credentials to logon to. This web service is a custom SharePoint web service: The idea is to do something in SharePoint with the SP object model, as soon as something happens on the exchange server. Anonymous access is, sadly, not an option.

Is there a way to tell exchange that it has to call the web service (.asmx by the way), where the notification is going to be sent to, with specific credentials (like username, password, domain)?
Next thing is that the exchange is running under another domain, than SharePoint is.
I've got SharePoint 2010 running locally on my notebook with Windows 7 (attached to our company domain) and Exchange 2010 is running inside a VM on the same notebook (hosting it's own active directory, not attached to company domain).

At the moment I'll always get the following error, 'cause Exchange tries to call the receiver web service without any credentials or logon information:

A notification for subscription [GQBtcnVleGNoYW5nZTIwMTAuZGV2LmxvY2FsEAAAANWqQz1YnDJBuYzqw/JGEpUcnOHPFD3NCA==] against endpoint [http://iclocal.upgnb055.local/_vti_bin/PushReceiver.asmx] couldn't be sent. (Send attempts: 2) Details: WebException: The remote server returned an error: (401) Unauthorized. StatusCode: Unauthorized Unauthorized at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at Microsoft.Exchange.Services.Core.NotificationServiceClient.HandleResponse(IAsyncResult responseAsyncResult)

Thanks in advance for your help!

Massimo
 
A

Allen Song

Hi,

For this issue, please post it into the Development forum of the Exchange.

Thanks

Allen

Allen Song
 
Status
Not open for further replies.
Top