Microsoft EWS api GetItem (mail) response ErrorInvalidUserPrincipalName but principal name is correct - exchangewebservices

I used Microsoft EWS api GetItem to get mail message item, but for certain users, server response ErrorInvalidUserPrincipalName (other users are work without errors), and I check principal name is correct with Microsoft Graph api.
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013"/>
<t:ExchangeImpersonation>
<t:ConnectingSID>
<t:PrincipalName>xxx#xxx.com</t:PrincipalName>
</t:ConnectingSID>
</t:ExchangeImpersonation>
</soap:Header>
<soap:Body>
<m:GetItem>
<m:ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
<t:IncludeMimeContent>true</t:IncludeMimeContent>
</m:ItemShape>
<m:ItemIds>
<t:ItemId Id="xxx"/>
</m:ItemIds>
</m:GetItem>
</soap:Body>
</soap:Envelope>
And server response ErrorInvalidUserPrincipalName.
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorInvalidUserPrincipalName</faultcode>
<faultstring xml:lang="en-US">The impersonation principal name is invalid.</faultstring>
<detail>
<e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorInvalidUserPrincipalName</e:ResponseCode>
<e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">The impersonation principal name is invalid.</e:Message>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
I used Microsoft Graph user api to check principal name, the principal name is same as I bring in EWS GetItem request but still get ErrorInvalidUserPrincipalName response.
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
"id": "zzz",
"businessPhones": [],
"displayName": "yyy",
"mail": "xxx#xxx.com",
"userPrincipalName": "xxx#xxx.com"
...
}
I tried to send same EWS GetItem with PrimarySmtpAddress tag rather than PrincipalName (smtp address is same as principal name), and it works without error, I don't know why use PrincipalName will get ErrorInvalidUserPrincipalName response even principal name looks correct.
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013"/>
<t:ExchangeImpersonation>
<t:ConnectingSID>
<t:PrimarySmtpAddress>xxx#xxx.com</t:PrimarySmtpAddress>
</t:ConnectingSID>
</t:ExchangeImpersonation>
</soap:Header>
<soap:Body>
<m:GetItem>
<m:ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
<t:IncludeMimeContent>true</t:IncludeMimeContent>
</m:ItemShape>
<m:ItemIds>
<t:ItemId Id="xxx"/>
</m:ItemIds>
</m:GetItem>
</soap:Body>
</soap:Envelope>
Is anyone occur same problem and can help me to solve this?
Thanks!

Does the Mailbox have a valid licence (the EXCHANGEDESKLESS Exchange Online Kiosk licence also doesn't have EWS access) and is it enabled and has been logged on to at least once. Typically when you get this error its because your trying to impersonate a disabled account.

After use PowerShell check, found UserPrincipalName is inconsistent on Exchange Server.
Get-Mailbox | Select-Object -ExpandProperty UserPrincipalName
Output:
aaa#aaa.com
But Graph api return UserPrincipalName is xxx#xxx.com
Then contact Microsoft support, they help to set UserPrincipalName consistent, after UserPrincipalName consistent, EWS api GetItem can work perfectly with PrincipalName.
Thanks.

Related

Google contact api returns Invalid XML Document error

While adding contacts using google contacts api, I have been getting status code 400, with Invalid XML Document error.
If I remove the following line the add contact api succeeds. However, this behaviour is not what I want. I would like to add it to the base group 6.
<gContact:groupMembershipInfo deleted="false"
href="http://www.google.com/m8/feeds/groups/binthi123#gmail.com/base/6"/>
The following is the body of the add new contact api post request:
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005">
<atom:category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact" />
<gd:name>
<gd:givenName>1234567890</gd:givenName>
</gd:name>
<gd:phoneNumber rel="http://schemas.google.com/g/2005#mobile" primary="true">
${phone_number}
</gd:phoneNumber>
<gContact:groupMembershipInfo deleted="false" href="http://www.google.com/m8/feeds/groups/binthi123#gmail.com/base/6" />
</atom:entry>
I solved the problem changing the tag <gContact:groupMembershipInfo>in <gd:groupMembershipInfo> , so any tag with <gContact> no longer works but only with <gd:>, this only when you create new contact if you update there isn't any problem
Our team ran into a variant of this problem where the Contacts API was returning "Invalid JSON" 400 error when posting a new contact (via XML). The problem was related to us setting the alt=json parameter; apparently there is a bug on Google's end that gets invoked if you ask for a JSON response from that method.

Data Replicator connection string for use with Data Hub

I am trying to set up Invantive Data Hub with Replicator. The default discovery creates entries for Exact Online and others, but there is no entry in settings.xml which shows me how to configure data cache.
This one exists for example:
<connection name="Exact Online (nl)" id="c149becf-01d3-4a58-9ee7-7369f34bdff5" description="{res:itgen_demo_exact_online_combined_nl}" sortingOrder="1000" authentication="Application" userLogonCodeMode="Auto" passwordMode="Auto" createdBy="jbu" createdOn="WS102" creationDate="2017-08-17T13:53:23.9351965+02:00">
<database order="0" createdBy="jbu" createdOn="WS102" creationDate="2017-08-17T13:53:23.9071956+02:00" provider="ExactOnlineAll" connectionString="apiUrl=https://start.exactonline.nl" />
</connection>
The console app has no editor for the settings.xml, so it must be done manually.
How can I configure the Replicator connection string to be used?
Using Google with different keywords, I've found a working setup. First Add a file settings-something.xml in the %USERPROFILE%\invantive.
The give it contents like below:
<?xml version="1.0" encoding="utf-16"?>
<settings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3" forcedefault="false">
<group name="Jurriaan" >
<connection name="Exact Online with PostgreSQL Data Cache" dataCacheConnectionString="provider=PostgreSql;connectionString={Server=dbserver;Database=db;User Id=db_owner;Password=db_pwd}" >
<database provider="ExactOnlineAll" connectionString="apiUrl=https://start.exactonline.nl" />
</connection>
</group>
</settings>
It would be handy when there would be a connection editor on Data Hub or at least a sample :-)

Paypal payment pro PayPal express order not sending confirmation email in Magento

I have a very long standing issue with PayPal Payments Pro in magento. If a customer places an order using PayPal express they don't receive the order email. If a customer pays with card they get it with no problems.
I have spent a lot of time investigating this with no joy at all. I am wondering if other people have had the same issue and if anyone has managed to solve it. I am running magento community 1.9.2.
The IPN seems to be working properly, and there are no orders in the email que.
Any help would be gratefully appreciated.
PayPal Payment Pro not send confirmation email facility.But you can achieve it by creating observer after payment receive.
You may use event checkout_onepage_controller_success_action. This can be used if your order success.
There is another event sales_order_payment_pay. This can be used if your order success. It may also use in your case.
1 ) Make custom config.xml for call observer file
The config.xml defines your module and declares your event listener for a given event (checkout_onepage_controller_success_action is sent when onepage checkout process is complete, sales_order_payment_pay is sent when the payment has been confirmed).
<?xml version="1.0"?>
<config>
<modules>
<Namespace_Modulename>
<version>0.1.0</version>
</Namespace_Modulename>
</modules>
<frontend>
<events>
<sales_order_payment_pay>
<observers>
<Namespace_Modulename_Customevent>
<type>singleton</type>
<class>Namespace_Modulename_Model_Observer</class>
<method>customFunction</method>
</Namespace_Modulename_Customevent>
</observers>
</sales_order_payment_pay>
</events>
</frontend>
</config>
2 ) create observer.php file inside your module/Model directory and paste this code
<?php
class Namespace_Modulename_Model_Observer
{
public function customFunction(Varien_Event_Observer $observer)
{
$order_id = $observer->getData('order_ids');
$order = Mage::getModel('sales/order')->load($order_id);
//your code here
}
}
Hope It's helpful for you.

EWS Partial sync soap request returns organizer name as appointment subject

I am currently working on a project where the system, which is a node.js web server subscribes to push notification for changes in the resource calendars of an Exchange server. We followed the MSDN documentation to subscribe and communicate with the Exchange server using SOAP requests.
We used SOAP request below to fetch the changes and store them in the local database of the web server. The '+roomCalId' and '+syncState+' values are replaced with room calendar Id and its corresponding sync state which are stored previously in the database when subscribing.
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013"></t:RequestServerVersion>
<t:TimeZoneContext>
<t:TimeZoneDefinition Name="UTC" Id="UTC"></t:TimeZoneDefinition>
</t:TimeZoneContext>
<t:ExchangeImpersonation>
<t:ConnectingSID>
<t:PrimarySmtpAddress>+roomCalId+</t:PrimarySmtpAddress>
</t:ConnectingSID>
</t:ExchangeImpersonation>
</soap:Header>
<soap:Body>
<m:SyncFolderItems>
<m:ItemShape>
<t:BaseShape>AllProperties</t:BaseShape>
</m:ItemShape>
<m:SyncFolderId>
<t:DistinguishedFolderId Id="calendar" />
</m:SyncFolderId>
<m:SyncState>+syncState+</m:SyncState>
<m:MaxChangesReturned>500</m:MaxChangesReturned>
<m:SyncScope>NormalItems</m:SyncScope>
</m:SyncFolderItems>
</soap:Body>
</soap:Envelope>
The process worked perfectly without any problems for the first few calendars. However, for newly created room calendars, the soap request above returns the organizer's name as appointment title instead of the actual title. Is there a reason why this might be happening?
Thats is a default setting on Room mailboxes where the Organiser name is used to replace the Subject of a Meeting. This is done for security reasons as most people have access to Meeting rooms but generally people like HR might not want people to see the subject of the meeting (eg meeting to talk about downsizing etc). You can change this setting using the Set-CalendarProcessing cmdlet https://technet.microsoft.com/en-us/library/dd335046(v=exchg.160).aspx and the AddOrganizerToSubject parameter

Openfire : No roster returned to user

We added jappix mini chat feature in our application in conjunction with Openfire 3.7.1 and a Mysql database.
HTTP Binding is enabled in Openfire admin console.
The chat was working well on another server but it seems that we cannot get rosters anymore from client.
We always get the following empty response from Openfire when building contact list (buddies) :
Get request :
<body xml:lang='fr' rid='827616' sid='ad92bb0e' xmlns='http://jabber.org/protocol/httpbind' key='26620f678e64cc9f04ea31b69525db88c9655545' >
<iq xmlns="jabber:client" type="get" id="1" xml:lang="fr">
<query xmlns="jabber:iq:roster"/>
</iq>
</body>
Response :
<body xmlns='http://jabber.org/protocol/httpbind'>
<iq xmlns="jabber:client" type="result" id="1" to="atinel#domain/Chat (1452607565973)">
<query xmlns="jabber:iq:roster"/>
</iq>
</body>
This response can be seen in the browser network logs or in the audit logs from Openfire.
I only manage to get a roster when creating a new one between two users.
The rosters can be found in the database and in admin console where we see two of them for this precise user (atinel).
We also checked that the SQL queries on "ofRoster" table were properly formed for each user connection.
This is the kind of response expected :
<body xmlns='http://jabber.org/protocol/httpbind'>
<iq xmlns="jabber:client" type="result" id="1" to="atinel#domain/Chat (1452608051572)">
<query xmlns="jabber:iq:roster">
<item jid="team#domain" name="IT Team" subscription="both"/>
<item jid="userdemo#domain" name="Demo user" subscription="both"/>
</query>
</iq>
</body>
Have you any idea to solve this problem ?
Maybe I have missed a property when configuring Openfire ?
I already have cleared the roster (and all other) caches and nothing changed, no more result when upgrading to 3.9.3.
Thanks.