473,574 Members | 2,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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();

}
Dec 22 '05 #1
0 1519

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5703
by: Ian | last post by:
The beginning of my assembly that I am getting the access error from looks like this. ********************************* Imports System.EnterpriseServices Imports System Imports System.Collections Imports System.Configuration Imports System.Data Imports System.Data.Common Imports System.Reflection
1
4380
by: moemeelaung | last post by:
Hi ASP/Windows experts out there I really need help with this Impersonate function. I have machine A and B. A hosts my ASP page which is to create a user account on the machine B. The machine are not on Domain and not in AD environment. I userstand the the web page from A is to create a user account on B should use Impersonate...
5
2049
by: paulp | last post by:
Greetings, I'm working on a CGI program that will run under MS IIS 5.0 and will browse folders on three other machines, building HTML pages that will provide links to these folders. Essentially, the CGI will connect to each machine in turn, doing the FindFirst/FindNext process based on the current criteria. It will select certain...
14
3436
by: Ian Frawley | last post by:
Anyone used the WindowsIdentity class with success? I find if I try to change the current identity to one that exists on another machine and then try to perform and action on that machine i.e. restart a service or list the available processes I keep getting access denied exceptions. Here is an example of my code: public extern static bool...
6
2385
by: Erez Shor | last post by:
Hi, I need to build and asp page which access a remote windows server's registry and create a registry key. In order for the ASP page to be able to access the registry on the remote server I need it to run using credentials supplied by the user. When using basic authentication this is not an issue since the user has to provide a user name...
1
6284
by: Svein Terje Gaup | last post by:
I have a website running on Windows 2000 Server, that should be able to retrieve data from a datawarehouse on another machine running Windows 2000 Server, SQL Server 2000 and SQL Server 2000 Analysis Services. It seems impossible to make the impersonation work. Every path I try seems to be blocked. Path number one: set <identity...
2
5260
by: rockdale | last post by:
Hi, all: My asp.net application calles MS speech 5.1 and generate a wav file on server's path. Everything runs perfectly on my development machine. But when I move the appl to production server, I always get ERROR: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)). First I thought its the permission problem, so I set...
4
5797
by: =?Utf-8?B?QXZhRGV2?= | last post by:
ASP.Net 2. We are migrating to Windows 2008 64 bit Server with IIS 7 from Windows 2003 32 Bit with IIS 6. A few library classes we wrote uses impersonation in code like explained in this article: http://support.microsoft.com/?id=306158#4 This doesn't work in Windows 2008 Server, we receive the following exception:
2
5328
by: =?Utf-8?B?bXVyYWRqYW1lcw==?= | last post by:
Yes, sorry I tried to make it clear in the original question that I want to get the user token of the service - ie. the account the service is running under. I know services don't have user tokens - I suspect users do have tokens, hence "user token", otherwise we might call them "service tokens" or somesuch :-) If you read the question...
0
7813
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7826
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8106
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6461
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5631
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5305
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3755
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1350
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1066
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.