logged in User using WhoAmIRequest class always returns "SYSTEM"

logged in User using WhoAmIRequest class always returns "SYSTEM"

This question has suggested answer(s)

I have a big issue that I am trying to resolve for more than a week. Appreciate if you could enlighten me.

 

 

If I run the below code directly via VS 2010, it returns me with the correct result.

If I tried to run the same code directly from IIS 7.5 (using CRMAppPool) it reurns "SYSTEM"

If I'm trying to get the logged in User in crm 2011 using WhoAmIRequest class , it always return the system user instead of the logged in user I don't know why??

 

Thank and really hope to get good answer from you soonest.

 

 

 

 

 

 

My code as below: (I have use the latest DLL file from SDK)

======================================

Public _service As IOrganizationService

 

 

 

Public Function GetOrganization() As

IOrganizationService

 

 

Dim organizationUri As New Uri("http://company:81/XRMServices/2011/Organization.svc"

)

 

 

Dim cred As New

ClientCredentials

 

 

Dim _serviceproxy As New OrganizationServiceProxy(organizationUri, Nothing, cred, Nothing

)

 

 

Me

._service = _serviceproxy

 

 

Dim who As New WhoAmIRequest

()

 

 

Dim whoResp As WhoAmIResponse = CType(_serviceproxy.Execute(who), WhoAmIResponse

)

 

 

Dim currentUserId As Guid = whoResp.UserId

Response.Write(currentUserId)

 

 

Return Me

._service

 

 

End

Function

 

All Replies