2014-11-21 116 views
1

我正在研究一個需要與Microsoft Dynamics CRM集成的PHP應用程序。我研究了直接在PHP和MSCRM服務器之間進行通信的方式,最終決定使用C#橋設計它,即PHP應用程序連接到與MSCRM交互的C#服務。PHP和C之間的安全通信#

現在我的問題是安全性,C#服務和MSCRM服務器之間的通信是安全的,但在PHP應用程序和C#服務之間,我對如何實現某種加密有點困惑。

基本上,我在尋找建議,有沒有人處理過這樣的問題?你做了什麼?有沒有一個簡單,安全的方法來做到這一點,還是一個複雜的過程?

+3

添加SSL/TLS到主機運行web服務,並確保您的php使用用戶名/密碼/密鑰系統對應用程序進行身份驗證,您會沒事的。 – Dave 2014-11-21 13:41:06

+0

感謝您的回覆,戴夫。我當然希望我能夠將SSL放在主機上,但問題是我可能無法始終控制服務器,但我仍然需要確保它的安全;所以如果你必須不使用SSL,那你會怎麼做? – 2014-11-21 18:16:51

+1

如果SSL不是選項,則必須使用消息級別加密來確保通信免受嗅探攻擊。查看WCF消息安全性。 http://msdn.microsoft.com/en-us/library/ff648863.aspx – MvdD 2014-11-21 23:33:10

回答

0

您可以讓PHP直接和安全地與CRM交談。額外的橋樑只是開銷,實際上並沒有提供太多好處。

這裏有一個博客帖子與CRM在線PHP的輔助類: http://www.hashtagcrm.com/?p=17

與助手剛開始,然後您需要任何特定的功能擴展。該助手甚至還包括一個樣本函數,演示如何添加自己的特定功能:在你的主程序

//Returns the Parent Account Name of the specified Contact 
    public function sampleFunction($contactid){ 

    $getParentCustomer = ' 
         <Retrieve xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
          <entityName>contact</entityName> 
          <id>'.$contactid.'</id> 
          <columnSet xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts"> 
          <a:AllColumns>false</a:AllColumns> 
          <a:Columns xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> 
           <b:string>parentcustomeridname</b:string> 
          </a:Columns> 
          </columnSet> 
         </Retrieve>'; 

    $getParentCustomerResult = $this->sendQuery($getParentCustomer, 'Retrieve'); 

    $responsedom = new DomDocument(); 
    $responsedom->loadXML($getParentCustomerResult); 
    $KeyValuePairs = $responsedom->getElementsbyTagName("KeyValuePairOfstringanyType"); 

    foreach($KeyValuePairs as $results) { 
     if ($results->childNodes->item(0)->nodeValue == "parentcustomeridname") { 
     return $results->childNodes->item(1)->childNodes->item(0)->nodeValue; 
     } 
     else { 
     return 'No Result'; 
     } 
    } 
    } 

然後,你可以運行這樣的事情:

require_once('dynamicsclient.php'); 
$dynamicsClient = new dynamicsClient(0); 

//prints the Parent Account name of the specified Contact ID 
echo $dynamicsClient->sampleFunction("<CONTACTID>");