code_junkie

CrmImpersonator and IFD

Nov 12th, 2011
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1. 'Microsoft.Crm.WebServices.Crm2007.CookieAndSoapHeaderAuthenticationProvider, Microsoft.Crm.WebServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' doesn't exist.
  2. Parameter name: Microsoft.Crm.WebServices.Crm2007.CookieAndSoapHeaderAuthenticationProvider, Microsoft.Crm.WebServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
  3. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
  4.  
  5. Exception Details: System.ArgumentException: 'Microsoft.Crm.WebServices.Crm2007.CookieAndSoapHeaderAuthenticationProvider, Microsoft.Crm.WebServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' doesn't exist.
  6. Parameter name: Microsoft.Crm.WebServices.Crm2007.CookieAndSoapHeaderAuthenticationProvider, Microsoft.Crm.WebServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
  7.  
  8. public string orgname;
  9. public string crmurl;
  10. public string metaurl;
  11. public bool offline;
  12.  
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. #region CRM URLs and Organization Name
  16.  
  17. //Determine Offline State from Host Name
  18. if (Request.Url.Host.ToString() == "127.0.0.1")
  19. {
  20. #region offline
  21. offline = true;
  22.  
  23. //Retrieve the Port and OrgName from the Registry
  24. //RegistryKey regkey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\MSCRMClient");
  25. //orgname = regkey.GetValue("ClientAuthOrganizationName").ToString();
  26. string portnumber = regkey.GetValue("CassiniPort").ToString();
  27.  
  28. //Construct the URLs
  29. string baseurl = "http://localhost:" + portnumber + "/mscrmservices/2007/";
  30. crmurl = baseurl + "crmservice.asmx";
  31. metaurl = baseurl + "metadataservice.asmx";
  32. #endregion
  33. }
  34. else
  35. {
  36. offline = false;
  37.  
  38. //Retrieve the URLs from the Registry
  39. //RegistryKey regkey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\MSCRM");
  40. //string ServerUrl = regkey.GetValue("ServerUrl").ToString();
  41. string ServerUrl = "http://192.168.1.152:5555/MSCRMServices";
  42. crmurl = ServerUrl + "/2007/crmservice.asmx";
  43. metaurl = ServerUrl + "/2007/metadataservice.asmx";
  44. Response.Write("ServerURL " + ServerUrl + "<br>");
  45. Response.Write("CRMURL: " + crmurl + "<br>");
  46. Response.Write("MetaURL: " + metaurl + "<br>");
  47.  
  48. //Retrieve the Query String from the current URL
  49. if (Request.QueryString["orgname"] == null)
  50. {
  51. orgname = string.Empty;
  52. }
  53. else
  54. {
  55. //Query String
  56. string orgquerystring = Request.QueryString["orgname"].ToString();
  57. if (string.IsNullOrEmpty(orgquerystring))
  58. {
  59. orgname = string.Empty;
  60. }
  61. else
  62. {
  63. orgname = orgquerystring;
  64. }
  65.  
  66. }
  67.  
  68. if (string.IsNullOrEmpty(orgname))
  69. {
  70. //Windows Auth URL
  71. if (Request.Url.Segments[2].TrimEnd('/').ToLower() == "isv")
  72. {
  73. orgname = Request.Url.Segments[1].TrimEnd('/').ToLower();
  74. }
  75.  
  76. //IFD URL
  77. if (string.IsNullOrEmpty(orgname))
  78. {
  79. string url = Request.Url.ToString().ToLower();
  80. int start = url.IndexOf("://") + 3;
  81. orgname = url.Substring(start, url.IndexOf(".") - start);
  82. }
  83. }
  84. Response.Write(orgname + "<br>");
  85. }
  86.  
  87. #endregion
  88. }
  89.  
  90. Execute as user =@username
  91. Select * from FilteredActivityPointer;
  92. revert
Add Comment
Please, Sign In to add comment