Get DefaultCredentials of one web app into another?

S

Simon Storr

We have a web app which links to another ASP.NET web application (namely the
Microsoft CRM). Our app is launched in a new browser window from a link in
the CRM. Our app is on the same server inside the same IIS site. Both are
using Windows Authentication.

Basically we are tearing our hair out trying to get the credentials (or at
least the user name) of the current user in the CRM so we can pass it into
our app. Is this in any way possible?!

Thanks in advance,

Simon
 
M

[MSFT]

Hi Simon,

You may get the user identity in ASP.NET application from following string:

context.User.Identity.Name()

This requires "anonymous access" is disabled on the virtual folder.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
F

fur face

hi Luke,

I tried that but it just gives the currently logged in Windows user - not
the user authenticated to the CRM.

Simon.
 
F

fur face

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
 
M

[MSFT]

Hi Simon,

Microsoft CRM uses integrated Microsoft Windows authentication to perform
authentication. If the with Anonymous mode , it will return null anyway.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top