Trying to impersonate

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ron Wallegie

    Trying to impersonate

    I'm trying to impersonate a admin user when retrieving picklist items in
    Microsoft CRM. When
    a windows 2000 user is opening the code it is getting a popup asking the
    username, password, and domain.

    Can someone please help??

    The coce i am using is this,

    System.Net.Cred entialCache MyCredentials = new System.Net.Cred entialCache();

    System.Net.Netw orkCredential MyNetCred =

    new System.Net.Netw orkCredential(@ "user",@"passwo rd",@"CRM");

    MyCredentials.A dd

    (new Uri(strDir + "BizUser.sr f"), "NTLM", MyNetCred);

    MyCredentials.A dd

    (new Uri(strDir + "CRMCustomizati on.srf"), "NTLM", MyNetCred);

    MyCredentials.A dd

    (new Uri(strDir + "CRMContact.srf "), "NTLM", MyNetCred);

    MyCredentials.A dd

    (new Uri(strDir + "CRMQuery.srf") , "NTLM", MyNetCred);

    //BizUser object

    bizUser = new Microsoft.Crm.P latform.Proxy.B izUser();

    bizUser.Credent ials = MyCredentials;

    bizUser.Url = strDir + "BizUser.sr f";

    // CRMCustomizatio n proxy object

    Microsoft.Crm.P latform.Proxy.C RMCustomization customization = new
    Microsoft.Crm.P latform.Proxy.C RMCustomization ();

    customization.C redentials = MyCredentials;

    customization.U rl = String.Concat(s trDir, "CRMCustomizati on.srf");

    //create CRM Contact proxy object

    Microsoft.Crm.P latform.Proxy.C RMContact contact = new
    Microsoft.Crm.P latform.Proxy.C RMContact();

    contact.Credent ials = MyCredentials;

    contact.Url = String.Concat(s trDir, "CRMContact.srf ");


    //create CRM Account proxy object

    Microsoft.Crm.P latform.Proxy.C RMAccount account = new
    Microsoft.Crm.P latform.Proxy.C RMAccount();

    account.Credent ials = System.Net.Cred entialCache.Def aultCredentials ;

    account.Url = String.Concat(s trDir, "CRMAccount.srf ");


    // Query proxy object

    Microsoft.Crm.P latform.Proxy.C RMQuery query = new
    Microsoft.Crm.P latform.Proxy.C RMQuery ();

    query.Credentia ls = MyCredentials;

    query.Url = strDir + "CRMQuery.s rf";


    try

    {

    Microsoft.Crm.P latform.Proxy.C UserAuth userAuth = bizUser.WhoAmI( );

    userAuth = this.bizUser.Wh oAmI();

    }


Working...