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.CredentialCache MyCredentials = new System.Net.CredentialCache();
System.Net.NetworkCredential MyNetCred =
new System.Net.NetworkCredential(@"user",@"password",@ "CRM");
MyCredentials.Add
(new Uri(strDir + "BizUser.srf"), "NTLM", MyNetCred);
MyCredentials.Add
(new Uri(strDir + "CRMCustomization.srf"), "NTLM", MyNetCred);
MyCredentials.Add
(new Uri(strDir + "CRMContact.srf"), "NTLM", MyNetCred);
MyCredentials.Add
(new Uri(strDir + "CRMQuery.srf"), "NTLM", MyNetCred);
//BizUser object
bizUser = new Microsoft.Crm.Platform.Proxy.BizUser();
bizUser.Credentials = MyCredentials;
bizUser.Url = strDir + "BizUser.srf";
// CRMCustomization proxy object
Microsoft.Crm.Platform.Proxy.CRMCustomization customization = new
Microsoft.Crm.Platform.Proxy.CRMCustomization();
customization.Credentials = MyCredentials;
customization.Url = String.Concat(strDir, "CRMCustomization.srf");
//create CRM Contact proxy object
Microsoft.Crm.Platform.Proxy.CRMContact contact = new
Microsoft.Crm.Platform.Proxy.CRMContact();
contact.Credentials = MyCredentials;
contact.Url = String.Concat(strDir, "CRMContact.srf");
//create CRM Account proxy object
Microsoft.Crm.Platform.Proxy.CRMAccount account = new
Microsoft.Crm.Platform.Proxy.CRMAccount();
account.Credentials = System.Net.CredentialCache.DefaultCredentials;
account.Url = String.Concat(strDir, "CRMAccount.srf");
// Query proxy object
Microsoft.Crm.Platform.Proxy.CRMQuery query = new
Microsoft.Crm.Platform.Proxy.CRMQuery ();
query.Credentials = MyCredentials;
query.Url = strDir + "CRMQuery.srf";
try
{
Microsoft.Crm.Platform.Proxy.CUserAuth userAuth = bizUser.WhoAmI();
userAuth = this.bizUser.WhoAmI();
}