Get DefaultCredentials of one web app into another?

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Get DefaultCredentials of one web app into another?

    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 Guest

  2. Similar Questions and Discussions

    1. DefaultCredentials problem?
      Hi All, this is the scenario: - "Hello World" web service on Machine A - winform client on Machine B - asp.net webform client on Machine B ...
    2. CredentialCache.DefaultCredentials Not working
      I am using the following method to call a web service from a windows application Dim a As New MachineReference.Service1 a.Credentials = s...
    3. 401 Unauthorized when using DefaultCredentials
      Hi all I hope this is the right newsgroup. I'm having a hard time making a web request from an authenticated process. Here's the scenario Managed...
    4. ASP.NET Impersonation, XmlUrlResolver, and DefaultCredentials
      I'm trying to write an ASP.NET page that does on-the-fly XML/XSL transformation. The code is as follows: --- Dim xmlPath As String =...
    5. DefaultCredentials and WebClient
      I'm trying to make a call inside an ASP.NET web application to an external quasi-web service (aka FrontPage Server Extensions): Dim rpcClient As...
  3. #2

    Default RE: Get DefaultCredentials of one web app into another?

    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! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    [MSFT] Guest

  4. #3

    Default Re: Get DefaultCredentials of one web app into another?

    hi Luke,

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

    Simon.

    "[MSFT]" <lukezhan@online.microsoft.com> wrote in message
    news:xL68jtdHEHA.3576@cpmsftngxa06.phx.gbl...
    > 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! [url]www.microsoft.com/security[/url]
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >

    fur face Guest

  5. #4

    Default Re: Get DefaultCredentials of one web app into another?

    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

    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/CrmSdk/htm/[/url]
    default.asp

    You may download it first anc check the sample code in it.

    Luke
    Microsoft Online Support

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

    [MSFT] Guest

  6. #5

    Default Re: Get DefaultCredentials of one web app into another?

    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]" <lukezhan@online.microsoft.com> wrote in message
    news:eS%23J8Y2JEHA.3800@cpmsftngxa10.phx.gbl...
    > 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
    >
    >
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/CrmSdk/htm/[/url]
    > default.asp
    >
    > You may download it first anc check the sample code in it.
    >
    > Luke
    > Microsoft Online Support
    >
    > Get Secure! [url]www.microsoft.com/security[/url]
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >

    fur face Guest

  7. #6

    Default Re: Get DefaultCredentials of one web app into another?

    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! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    [MSFT] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139