Luke,
Thanks, I already have the SDK. Here's the code I'm trying to use which is
based on the 'create a user' example in there -
using System;
using System.Net;
using Microsoft.CRM.Proxy;
private Uri FUri;
private string FServiceDir;
..
..
..
private CUserAuth GetBizUser(BizUser aBizUser)
{
// log in
aBizUser.Credentials = CredentialCache.DefaultCredentials; // Always
blank...?
aBizUser.Url = FServiceDir + "BizUser.srf";
CUserAuth lAuth;
try
{
lAuth = aBizUser.WhoAmI();
return lAuth;
}
catch (Exception ex)
{
throw new Exception("User could not be validated. E:"+ex.Message);
}
}
// constructor
public CRMClass(string aUri)
{
string lCRMServerUrl = "http://"+aUri;
FUri = new Uri(lCRMServerUrl);
FServiceDir = lCRMServerUrl + "/MSCRMServices/";
}
GetBizUser should return the CUserAuth class which contains the user info.
The problem is DefaultCredentials just returns the first user which it
thinks is valid (which for some reason always turns out blank - anonymous
user??) NOT the user who logged into the CRM via the IE login box (always
ask for password is enabled in IE). Result - it throws the 'user could not
be validated' exception (not authorized)... I don't want the user who logged
into Windows (which all the examples I can find seem to work for).
The code is actually wrapped in a WSE web service (MSCRMWSWse), which I know
must have anonymous access, but I'm passing in the app's credentials to the
proxy instance of the service I'm using, which in turn should get passed
into the CRM SDK in my code above? -
MSCRMProxy.MSCRMWSWse lCRMWS = new myApp.MSCRMProxy.MSCRMWSWse();
lCRMWS.Credentials = FAppCredentials; // current credentials for calling app
string lName = lCRMWS.GetUserName(); // function in WS to return CRM user
name from the CUserAuth
I don't see how I can get the user who authenticated to the CRM in the first
place via the IE login box? According to the docs
CredentialCache.DefaultCredentials returns the FIRST user which is
authenticated, I can't find any way of finding a PARTICULAR user...?
Simon