locked
CRM 2011 On-Premise (no ADFS): Windows/AD Authentication to Organization Service Possible? System.Net.CredentialCache.DefaultCredentials? RRS feed

  • Question

  • Hi there,

    I'm writing a custom web service that will be doing basic CRUD against a CRM 2011 On-Premise instance over local http without ADFS. The custom web service uses an app pool that runs with the Identity of a CRM user. I would like all CRM web service calls to happen in the context of the app pool identity AD user.

    In 4.0, this is really easy. I'd just connect to the 4.0 web service and pass in System.Net.CredentialCache.DefaultCredentials and it would just work.

    In 2011, I can't figure out how to do this without hard-coding credentials so that it would look something like this:

            ClientCredentials clientCredentials = new ClientCredentials();
            clientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("HARDCODEDUSERNAME", "HARDCODEDPASSWORD", "DOMAIN");
            using (_serviceProxy = new OrganizationServiceProxy(new Uri("http://localhost/EECRM/XRMServices/2011/Organization.svc")
                , null
                , clientCredentials
                , null))
            {

            }

     I would like to avoid using the 4.0 web services if possible. Anyone know how to use Windows Authentication to allow for integrated AD authentication with the 2011 service?

    Thanks!

    Phil


    Phil Edry – Altriva Solutions – http://www.altriva.com/AltrivaBlog.aspx
    Tuesday, May 31, 2011 5:35 PM

Answers

  • Try this:

     

            ClientCredentials creds = new ClientCredentials();
            creds.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
            //creds.Windows.ClientCredential = new NetworkCredential(username, userpassword, userDomain); //HardCoded credentials
    
            using (var serviceProxy = new OrganizationServiceProxy(serviceConfig, creds))
            {
    
              CallSdk(serviceProxy);
            }
    


    Gonzalo | gonzaloruizcrm.blogspot.com

    Tuesday, May 31, 2011 7:02 PM
    Moderator

All replies

  • Try this:

     

            ClientCredentials creds = new ClientCredentials();
            creds.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
            //creds.Windows.ClientCredential = new NetworkCredential(username, userpassword, userDomain); //HardCoded credentials
    
            using (var serviceProxy = new OrganizationServiceProxy(serviceConfig, creds))
            {
    
              CallSdk(serviceProxy);
            }
    


    Gonzalo | gonzaloruizcrm.blogspot.com

    Tuesday, May 31, 2011 7:02 PM
    Moderator
  • Bingo. Thanks Gonzalo.
    Phil Edry – Altriva Solutions – http://www.altriva.com/AltrivaBlog.aspx
    Tuesday, May 31, 2011 7:38 PM