locked
Windows Security Popup When Retrieving User Data RRS feed

  • Question

  • I am using a C# library to make calls to an on-premise CRM installation to retrieve user data. When I made my first call to retrieve the user's id:

     Guid userid = ((WhoAmIResponse)organizationProxy.Execute(new WhoAmIRequest())).UserId;

    I would receive a Windows Security popup requesting my username/password. I resolved this problem by setting the following property:

    authCredentials.ClientCredentials.SupportInteractive = false;

    My call then completed without receiving the prompt and the userid was retrieved successfully.

    My next problem is to use the GUID to retrieve the user's email address:

    var x = organizationProxy.Retrieve("systemuser", userid, new ColumnSet("internalemailaddress"));

    However, even though this line appears directly underneath the call for the userid I once again receive the Windows Security popup. I can cancel the popup, step through (F11) the call, and see that the information I want is being returned. The only problem is the Windows Security popup and I'm a bit confused about why I receive it for one call and not the other.

    Is there a difference between .Execute and .Retrieve? They are both contained in the same using statement which is referencing the same credentials:

       using (OrganizationServiceProxy organizationProxy =
                            GetProxy<IOrganizationService, OrganizationServiceProxy>(orgServiceManagement, credentials))
                    {

    How do I suppress/avoid the Windows Security popup for the call for the email address? And this cannot be a browser configuration change or other setting. It must be code, this is a deployable solution and must not be dependent on users or admins making changes.

    Thanks for any help.

    Friday, December 16, 2016 1:42 PM

Answers

  • In case anyone else has the same problem in the future and stumbles across this post -

    It appears that I can execute some calls by F11'ing through them in the debugger while others will produce a login prompt. I ended up testing for "correctness" by running the application past the calls to CRM before stopping on any breakpoints and - in my case - everything worked as it should.

    I do not know why one call produces a prompt and the other does not when I'm stepping through, they use the same credentials and are in the same using statement, but nevertheless, there you have it.

    • Marked as answer by JSChicago Friday, December 23, 2016 5:46 PM
    Monday, December 19, 2016 7:36 PM

All replies

  • In case anyone else has the same problem in the future and stumbles across this post -

    It appears that I can execute some calls by F11'ing through them in the debugger while others will produce a login prompt. I ended up testing for "correctness" by running the application past the calls to CRM before stopping on any breakpoints and - in my case - everything worked as it should.

    I do not know why one call produces a prompt and the other does not when I'm stepping through, they use the same credentials and are in the same using statement, but nevertheless, there you have it.

    • Marked as answer by JSChicago Friday, December 23, 2016 5:46 PM
    Monday, December 19, 2016 7:36 PM
  • You can get the logged in user ID by using this command:-

    
    public void Execute(IServiceProvider serviceProvider)
    {
        IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
            IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
        Guid userId = context.InitiatingUserId;
    }



    Regards Faisal

    Tuesday, December 20, 2016 9:41 AM
  • Thanks, but getting the userid is not the problem and does not address my original question.
    Tuesday, December 20, 2016 2:27 PM
  • Check internet explorer settings:-

    http://www.crmsoftwareblog.com/2015/06/internet-explorer-settings-microsoft-dynamics-crm-compatibility/


    Regards Faisal

    Wednesday, December 21, 2016 9:46 AM
  • Read the original post -

    "...And this cannot be a browser configuration change or other setting. It must be code, this is a deployable solution and must not be dependent on users or admins making changes"

    Friday, December 23, 2016 5:45 PM