Get DefaultCredentials of one web app into another?

Discussion in 'ASP .Net Security' started by Simon Storr, Apr 8, 2004.

  1. Simon Storr

    Simon Storr Guest

    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
     
    Simon Storr, Apr 8, 2004
    #1
    1. Advertising

  2. Simon Storr

    [MSFT] Guest

    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.)
     
    [MSFT], Apr 9, 2004
    #2
    1. Advertising

  3. Simon Storr

    fur face Guest

    hi Luke,

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

    Simon.

    "[MSFT]" <> wrote in message
    news:...
    > 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.)
    >
     
    fur face, Apr 20, 2004
    #3
  4. Simon Storr

    [MSFT] Guest

    [MSFT], Apr 21, 2004
    #4
  5. Simon Storr

    fur face Guest

    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

    "[MSFT]" <> wrote in message
    news:eS%...
    > Hi Simon,
    >
    > Sorry, I may misunderstand your question. For account in Windows CRM, we
    > cannot retrieve it simply in ASP.NET. You need Microsoft CRM SDK
    >
    >

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/CrmSdk/htm/
    > default.asp
    >
    > You may download it first anc check the sample code in it.
    >
    > Luke
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
     
    fur face, Apr 21, 2004
    #5
  6. Simon Storr

    [MSFT] Guest

    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.)
     
    [MSFT], Apr 22, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. loveNUNO
    Replies:
    2
    Views:
    922
    loveNUNO
    Nov 20, 2003
  2. Maras
    Replies:
    0
    Views:
    118
    Maras
    Jun 17, 2004
  3. SP
    Replies:
    0
    Views:
    155
  4. Rob R. Ainscough
    Replies:
    3
    Views:
    331
    Rob R. Ainscough
    Jun 14, 2005
  5. Robert Cohen
    Replies:
    3
    Views:
    275
    Andrew Durstewitz
    Jul 15, 2003
Loading...

Share This Page