Benutzer mit den meisten Antworten
Ermittlung des aktuellen Users über https schlägt fehl:

Frage
-
Hallo NG, folgenees Problem: ich ermittle mit dieser Funktion den Username des aktuellen Users. Diese funktioniert im Intranet auch anstandlos. Wenn ich aber über das IFD komme, sprich wenn ich crm über https (publiziert über ISA-Server) aus dem Internet heraus aufrufe funktioniert es nicht mehr. Hat mir jemand eine Idee an was dies liegen könnte?
GetUserId = function() { var owner = crmForm.all.ownerid.DataValue; var strOwnerId= owner[0].id; var soapBody = "<soap:Body>"+ "<Execute xmlns='http://schemas.microsoft.com/crm/2007/"+ "WebServices'>"+ "<Request xsi:type='WhoAmIRequest' />"+ "</Execute></soap:Body>"; var soapXml = "<soap:Envelope " + "xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' "+ "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' "+ "xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"; soapXml += GenerateAuthenticationHeader(); soapXml += soapBody; soapXml += "</soap:Envelope>"; var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); xmlhttp.open("POST", "/MSCRMservices/2007/crmservice.asmx", false); xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); xmlhttp.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Execute"); xmlhttp.send(soapXml); xmlDoc= new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc.loadXML(xmlhttp.responseXML.xml); try { var rawUserid = xmlDoc.getElementsByTagName("UserId")[0].childNodes[0].nodeValue; userid = "{"+rawUserid.toUpperCase()+"}"; } catch (e) { err = xmlDoc.getElementsByTagName("description")[0].childNodes[0].nodeValue; alert("Error :"+e.description+" : "+err); } }
Daraus ergibt sich dann dies:<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'> <soap:Header> <CrmAuthenticationToken xmlns="http://schemas.microsoft.com/crm/2007/WebServices"> <AuthenticationType xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">0</AuthenticationType> <CrmTicket xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes"></CrmTicket> <OrganizationName xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">OrgaName</OrganizationName> <CallerId xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">00000000-0000-0000-0000-000000000000</CallerId> </CrmAuthenticationToken></soap:Header><soap:Body> <Execute xmlns='http://schemas.microsoft.com/crm/2007/WebServices'><Request xsi:type='WhoAmIRequest' /></Execute> </soap:Body></soap:Envelope> <br/><br/><br/><br/><br/><br/>
--> An dieser Stelle kommt dann: objekt nicht gefunden...
var rawUserid = xmlDoc.getElementsByTagName("UserId")[0].childNodes[0].nodeValue
Vielen Dank für eure Hilfe!
Gruß Benni
Antworten
-
Hallo Benni,
die Server URL steht in einer globalen Variable, siehe:
http://msdn.microsoft.com/en-us/library/cc150876.aspx
Viele Grüße
Michael Sulz
axcentro GmbH
MVP für Microsoft Dynamics CRM- Als Antwort markiert JuergenBeckModerator Mittwoch, 6. Januar 2010 09:42
Alle Antworten
-
Hallo Benni,
ich benutze folgende Funktion, die auch bei IFD funktioniert. Du must nur die URL in der ersten Zeile anpassen:
var SERVER_URL = "https://demo.crm.de";
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.open("POST", SERVER_URL + "/mscrmservices/2007/crmservice.asmx", false);
xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlhttp.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Execute");
var soapBody = "<soap:Body>"+
"<Execute xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<Request xsi:type='WhoAmIRequest' />"+
"</Execute></soap:Body>";
var soapXml = "<soap:Envelope " +
"xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' "+
"xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' "+
"xmlns:xsd='http://www.w3.org/2001/XMLSchema'>";
soapXml += GenerateAuthenticationHeader();
soapXml += soapBody;
soapXml += "</soap:Envelope>";
xmlhttp.send(soapXml);
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.loadXML(xmlhttp.responseXML.xml);
var userid = xmlDoc.getElementsByTagName("UserId")[0].childNodes[0].nodeValue;
var buid = xmlDoc.getElementsByTagName("BusinessUnitId")[0].childNodes[0].nodeValue;
var orgid = xmlDoc.getElementsByTagName("OrganizationId")[0].childNodes[0].nodeValue;
alert("UserId: " + userid + "\r\nBusinessUnitId: " + buid + "\r\nOrganizationId: " + orgid);
Viele Grüße
Michael Sulz
axcentro GmbH
MVP für Microsoft Dynamics CRM- Als Antwort vorgeschlagen Michael Sulz Montag, 21. September 2009 06:53
-
Hallo Benni,
eine gute Frage. Könnt ihr denn nicht die externe URL zumindest für die Abfrage nutzen. Die Auflösung des Namens sollte doch auch im internen LAN kein Problem darstellen.
Viele Grüße
Michael Sulz
axcentro GmbH
MVP für Microsoft Dynamics CRM -
Hi Michael,
leider net - intern arbeiten wir mit Proxy-Server. Der filtern das aus dass das im LAN ist. die andere Connection geht aber über https und ausschließlich über Internet.
Alternativ muss man eben die aktuelle URL auslesen und sich daraus die URL basteln.
Viele Grüße
Benni -
Hallo Benni,
die Server URL steht in einer globalen Variable, siehe:
http://msdn.microsoft.com/en-us/library/cc150876.aspx
Viele Grüße
Michael Sulz
axcentro GmbH
MVP für Microsoft Dynamics CRM- Als Antwort markiert JuergenBeckModerator Mittwoch, 6. Januar 2010 09:42