interrogazione CrmDataContext.GetEntities - ERRORE: 0x80040204 - autenticazione utente non valido

StackOverflow https://stackoverflow.com/questions/6802124

Domanda

Ho creato dominio utente 'mrossi' in Active Directory e ho aggiunto che account di dominio come un utente in Dynamics CRM. Il mio obiettivo è quello di eseguire codice con un account di servizio che si trova nel PrivUserGroup per l'organizzazione durante la rappresentazione 'mrossi'. I istanziata la CrmDataContext facendolo passare un'istanza di CrmConnection. Quando si chiama il costruttore della CrmConnection lo passo il nome della mia stringa di connessione nel file di configurazione dell'applicazione poi ho impostato la proprietà ImpersonatedUser per l'id utente del sistema di 'mrossi'. Una cosa da notare è che sto usando un'applicazione console per eseguire questo. Visualizza il mio codice qui sotto:

stringa di connessione nel app.config:

<add name="Crm" connectionString="Authentication Type=AD; Server=http://dev01/myorg; User ID=myorgdomain\sv-crm; Password=password123" />

CrmDataContext e il codice GetEntities:

var connection = new CrmConnection("Crm");
connection.ImpersonatedUser = Guid.Parse("1937F45C-8EB4-E011-8FE4-005056887B79");

var crm = new CrmDataContext(connection);
var contacts = crm.GetEntities("contacts")

if(contacts.Count() > 0)  //the call to Count() is where the error gets thrown. Invalid user auth.
  //do something

Non ho problemi quando si cerca di impersonate con il mio id utente del sistema che è legato al mio account di dominio AD che sto entrato come durante l'esecuzione dei test. Ottengo risultati indietro più che bene quindi so che non v'è alcun problema con l'account di servizio che viene utilizzato per eseguire il codice. Ho anche assegnato 'jsmith' alla stessa unità di business e l'ho messo negli stessi ruoli che io sono in (che è amministratore di sistema) e ho ancora ottenere l'autenticazione utente non valido. Cosa potrei mancare. Di seguito è riportato informazioni di errore nel file di traccia sul server. Nelle informazioni di traccia sotto l'unica cosa che non sporgono è la prima riga: "[2011-07-22 18: 14: 08.0] Processo: w3wp | Organizzazione: f827deb3-c6cc-DF11-bc07-005056887b79 | Discussione: 6 | categoria: eccezione | User: 822138f1-C574-e011-9dca-005056887b79 | Livello: errore | CrmException..ctor *". L'ID utente che si sta display è il mio utente del sistema id. Sembra che avrebbe mostrato l'id dell'account del servizio dalla stringa di connessione o l'id 'jblow' che viene rappresentato. Tutte le idee sarebbe molto apprezzato.

[2011-07-22 18:14:08.0] Process: w3wp |Organization:f827deb3-c6cc-df11-bc07-005056887b79 |Thread:    6 |Category: Exception |User: 822138f1-c574-e011-9dca-005056887b79 |Level: Error | CrmException..ctor
at CrmException..ctor(Int32 errorCode, Object[] arguments)
at SecurityHelper.VerifyAndReturnCurrentCallerId(Guid userId, Guid callerId, Guid orgId)
at CrmWebService.get_CurrentCallerId()
at CrmService.Execute(Request request)
at RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at LogicalMethodInfo.Invoke(Object target, Object[] values)
at WebServiceHandler.Invoke()
at WebServiceHandler.CoreProcessRequest()
at SyncSessionlessHandler.ProcessRequest(HttpContext context)
at CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at ApplicationStepManager.ResumeSteps(Exception error)
at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
at HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
>Crm Exception: Message: Invalid user auth., ErrorCode: -2147220988
[2011-07-22 18:14:08.0] Process: w3wp |Organization:f827deb3-c6cc-df11-bc07-005056887b79 |Thread:    6 |Category: Platform.Sdk |User: 822138f1-c574-e011-9dca-005056887b79 |Level: Error |   CompositeSoapExtensionExceptionHandler.Handle
at CompositeSoapExtensionExceptionHandler.Handle(Stream to, Stream from, Exception exception)
at CrmAuthenticationSoapExtensionBase.ProcessMessage(SoapMessage message)
at SoapMessage.RunExtensions(SoapExtension[] extensions, Boolean throwOnException)
at SoapServerProtocol.WriteException(Exception e, Stream outputStream)
at WebServiceHandler.WriteException(Exception e)
at WebServiceHandler.Invoke()
at WebServiceHandler.CoreProcessRequest()
at SyncSessionlessHandler.ProcessRequest(HttpContext context)
at CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at ApplicationStepManager.ResumeSteps(Exception error)
at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
at HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
>CrmSoapExtension detected CrmException:
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> Microsoft.Crm.CrmException: Invalid user auth.
at Microsoft.Crm.Sdk.SecurityHelper.VerifyAndReturnCurrentCallerId(Guid userId, Guid callerId, Guid orgId)
at Microsoft.Crm.WebServices.Crm2007.CrmWebService.get_CurrentCallerId()
at Microsoft.Crm.Sdk.Crm2007.CrmService.Execute(Request request)
--- End of inner exception stack trace --- 

UPDATE 7/25: Ho deciso di eseguire un test effettuando una chiamata, come ho fatto con il CrmDataContext dove il CrmConnection.ImpersonatedUser è impostato sul jsmith id. Poi ho fatto un'altra chiamata (esattamente lo stesso query) utilizzando il vecchio approccio di scuola dove si costruisce il QueryExpression e passarlo nel CrmService in cui la proprietà CallerId del CrmAuthenticationToken è impostato l'ID per jsmith. L'utilizzo CrmDataContext non riuscita con l'errore "Aut utente non valido", ma l'altra chiamata utilizzando l'funzionato benissimo CrmService e QueryExpression. Ho usato violinista a guardare la richiesta HTTP prima per ciascuna di quelle chiamate. La richiesta grezzo era esattamente lo stesso sia per le chiamate tranne per una cosa .... L'Negoziare token nel intestazione di autorizzazione della richiesta. Ho fatto entrambe le chiamate, una dopo l'altra, nella mia console app e che producono diversi Negoziare gettoni. Questo è avuto modo di essere il problema, anche se non so come risolvere. Sembra che questo è un bug nei avanzata Developer Extensions. Qui di seguito sono il http prima per entrambi.

--using CrmDataContext
POST http://myserver/MSCRMServices/2007/CrmService.asmx HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.235)
VsDebuggerCausalityData: uIDPo6mcKDyuc+pPqk3LRv81TrIAAAAA/j8K/SLE5EivZ+mzg1+doYkmNLjkHbFHmbD9UyYmHFEACQAA
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://schemas.microsoft.com/crm/2007/WebServices/Execute"
Accept-Encoding: gzip,gzip
Authorization: Negotiate YIIIrgYGKwYBBQUCoIIIojCCCJ6g.....
Host: myserver
Content-Length: 1281
Expect: 100-continue

<?xml version="1.0" encoding="utf-8"?>
<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>
<OrganizationName xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">myorg</OrganizationName>
<CallerId xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">1937f45c-8eb4-e011-8fe4-005056887b79</CallerId>
</CrmAuthenticationToken>
</soap:Header>
<soap:Body>
<Execute xmlns="http://schemas.microsoft.com/crm/2007/WebServices">
<Request xsi:type="RetrieveMultipleRequest" ReturnDynamicEntities="true">
<Query xmlns:q1="http://schemas.microsoft.com/crm/2006/Query" xsi:type="q1:QueryExpression">
<q1:EntityName>contact</q1:EntityName>
<q1:ColumnSet xsi:type="q1:AllColumns" />
<q1:Distinct>false</q1:Distinct>
<q1:PageInfo>
<q1:PageNumber>1</q1:PageNumber>
<q1:Count>100</q1:Count>
</q1:PageInfo>
<q1:LinkEntities />
<q1:Criteria>
<q1:FilterOperator>And</q1:FilterOperator>
<q1:Conditions />
<q1:Filters />
</q1:Criteria>
<q1:Orders />
</Query>
</Request>
</Execute>
</soap:Body>
</soap:Envelope>


--call using CrmService with QueryExpression
POST http://myserver/MSCrmServices/2007/CrmService.asmx HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.235)
VsDebuggerCausalityData: uIDPo8cVsRu/YZBCl+8cnC9j5fwAAAAAGni8rU7A/Uy4JYm/bi/S6d/soXPiw+xBoKSYCD/1KRIACQAA
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://schemas.microsoft.com/crm/2007/WebServices/Execute"
Authorization: Negotiate YIIG5wYGKwYBBQUCoIIG2zCCBtegMDAuBgkqhk.....
Host: myserver
Content-Length: 1219
Expect: 100-continue

<?xml version="1.0" encoding="utf-8"?>
<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>
<OrganizationName xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">myorg</OrganizationName>
<CallerId xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">1937f45c-8eb4-e011-8fe4-005056887b79</CallerId>
</CrmAuthenticationToken>
</soap:Header>
<soap:Body>
<Execute xmlns="http://schemas.microsoft.com/crm/2007/WebServices">
<Request xsi:type="RetrieveMultipleRequest" ReturnDynamicEntities="false">
<Query xmlns:q1="http://schemas.microsoft.com/crm/2006/Query" xsi:type="q1:QueryExpression">
<q1:EntityName>contact</q1:EntityName>
<q1:ColumnSet xsi:type="q1:AllColumns" />
<q1:Distinct>false</q1:Distinct>
<q1:PageInfo>
<q1:PageNumber>1</q1:PageNumber>
<q1:Count>100</q1:Count>
</q1:PageInfo>
<q1:Criteria>
<q1:FilterOperator>And</q1:FilterOperator>
</q1:Criteria>
</Query>
</Request>
</Execute>
</soap:Body>
</soap:Envelope>
È stato utile?

Soluzione 2

Non ho mai capito il problema. Ma, il mio lavoro-around è quello di costruire solo una stringa di connessione in fase di esecuzione che contiene il nome utente e la password della persona vorrei impersonare tramite la proprietà CallerId. Quindi voglio davvero essere impersonati e credo che per la mia situazione non ha molta importanza.

Altri suggerimenti

Sembra che si potrebbe aver trovato un bug. Vorrei aprire un ticket di supporto gratuito con Microsoft @ 1-877-276-2464. Sarebbero più veloce con risoluzione di quello che si sta trovando qui e il risultato sarebbe conclusiva.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top