Can anyone tell me how I can imitate the bizUser.WhoAmI? I am writing an
app to access the CRM object model. I've used the examples from the CRM SDK.
I need to run from my local development machine and access CRM.

I may have the merchantid in CUserAuth wrong, can anyone tell me what DB
Column this is tied to?

I am getting an Unathorized Error, I am sure that the UserID I am using is
correct and has admin rights.

I've tried the following:

Dim bizUser As mcp.BizUser = New mcp.BizUser
bizUser.Credentials = System.Net.CredentialCache.DefaultCredentials
bizUser.Url = strDir + "BizUser.srf"

Dim account As MCP.CRMAccount = New MCP.CRMAccount
account.Credentials = System.Net.CredentialCache.DefaultCredentials
account.Url = strDir + "CRMAccount.srf"

Dim strAccountId As String = "accountid here"

Dim userAuth As New mcp.CUserAuth
userAuth.UserId = "userid here"
userAuth.MerchantId = "ownerbusinessunitid here"

' Set up the columns that you want to retrieve
Dim strColumnSetXml As String = "<columnset>"
strColumnSetXml += "<column>name</column>"
strColumnSetXml += "<column>accountid</column>"
strColumnSetXml += "</columnset>"

'Retrieve the account
Dim strResultXml As String = account.Retrieve(userAuth, strAccountId,
strColumnSetXml)

Thanks in Advance,
Rick

Re: bizUser.WhoAmI - Security by Rick

Rick
Mon Aug 08 16:57:18 CDT 2005

I figured it out on my own, using the sytem.Net.NetworkCredential object:

Dim MyCredentials As System.Net.CredentialCache = New
System.Net.CredentialCache
Dim MyNetCred As System.Net.NetworkCredential = New
System.Net.NetworkCredential(username, password, domain)

MyCredentials.Add(New Uri(strDir + "BizUser.srf"), "NTLM", MyNetCred)
MyCredentials.Add(New Uri(strDir + "CRMAccount.srf"), "NTLM", MyNetCred)

Dim bizUser As Microsoft.CRM.Proxy.BizUser = New Microsoft.CRM.Proxy.BizUser
bizUser.Credentials = mycredentials
bizUser.Url = strDir + "BizUser.srf"

Dim account As Microsoft.CRM.Proxy.BizUser.CRMAccount = New
Microsoft.CRM.Proxy.BizUser.CRMAccount
account.Credentials = mycredentials
account.Url = strDir + "CRMAccount.srf"

Dim userAuth As New mcp.CUserAuth

' Set up the columns that you want to retrieve
Dim strColumnSetXml As String = "<columnset>"
strColumnSetXml += "<column>name</column>"
strColumnSetXml += "<column>accountid</column>"
strColumnSetXml += "</columnset>"

'Retrieve the account
Dim strResultXml As String = account.Retrieve(userAuth, strAccountId,
strColumnSetXml)

Rick

"Rick" <test@test.com> wrote in message
news:%230l8juEnFHA.3544@TK2MSFTNGP15.phx.gbl...
> Can anyone tell me how I can imitate the bizUser.WhoAmI? I am writing an
> app to access the CRM object model. I've used the examples from the CRM
> SDK. I need to run from my local development machine and access CRM.
>
> I may have the merchantid in CUserAuth wrong, can anyone tell me what DB
> Column this is tied to?
>
> I am getting an Unathorized Error, I am sure that the UserID I am using is
> correct and has admin rights.
>
> I've tried the following:
>
> Dim bizUser As mcp.BizUser = New mcp.BizUser
> bizUser.Credentials = System.Net.CredentialCache.DefaultCredentials
> bizUser.Url = strDir + "BizUser.srf"
>
> Dim account As MCP.CRMAccount = New MCP.CRMAccount
> account.Credentials = System.Net.CredentialCache.DefaultCredentials
> account.Url = strDir + "CRMAccount.srf"
>
> Dim strAccountId As String = "accountid here"
>
> Dim userAuth As New mcp.CUserAuth
> userAuth.UserId = "userid here"
> userAuth.MerchantId = "ownerbusinessunitid here"
>
> ' Set up the columns that you want to retrieve
> Dim strColumnSetXml As String = "<columnset>"
> strColumnSetXml += "<column>name</column>"
> strColumnSetXml += "<column>accountid</column>"
> strColumnSetXml += "</columnset>"
>
> 'Retrieve the account
> Dim strResultXml As String = account.Retrieve(userAuth, strAccountId,
> strColumnSetXml)
>
> Thanks in Advance,
> Rick
>