public function AuthenticateUser() { $SOAPresult = GetSOAPResponse('https://login.microsoftonline.com/RST2.srf', $this->BuildOCPSoap()); $responsedom = new DomDocument(); $responsedom->loadXML($SOAPresult); $cipherValues = $responsedom->getElementsbyTagName("CipherValue"); if (isset($cipherValues) && $cipherValues->length > 0) { $this->securityToken0 = $cipherValues->item(0)->textContent; $this->securityToken1 = $cipherValues->item(1)->textContent; $this->keyIdentifier = $responsedom->getElementsbyTagName("KeyIdentifier")->item(0)->textContent; } else { return null; } }
function WhoAmIRequest($request) { $authentication = new Authentication('*****@*****.**', 'kennethA20869'); $xml = ' <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> ' . getHeader('Execute', $authentication) . ' <s:Body> <Execute xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <request i:type="b:WhoAmIRequest" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:b="http://schemas.microsoft.com/crm/2011/Contracts"> <a:Parameters xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic" /> <a:RequestId i:nil="true" /> <a:RequestName>WhoAmI</a:RequestName> </request> </Execute> </s:Body> </s:Envelope>'; return GetSOAPResponse('https://thehangar.crm.dynamics.com/XRMServices/2011/OrganizationData.svc', $xml); }