473,386 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

using impersonation in code

I am new to asp.net and am trying to open a word document readonly from the
server. I am not sure how to do that either, but what I tried gave me an
error re: rights. I read the following on impersonation, but got an error
trying it. It is in C# and I translated to vb.net, so perhaps I translated
incorrectly. Could someone show me what to do:

Thanks so much -- below is from the article I mentioned.

To impersonate the authenticating user (User.Identity) only when you run a
particular section of code, you can use the code to follow. This method
requires that the authenticating user identity is of type WindowsIdentity.

System.Security.Principal.WindowsImpersonationCont ext impersonationContext;
impersonationContext =
((System.Security.Principal.WindowsIdentity)User.I dentity).Impersonate();

//Insert your code that runs under the security context of the
authenticating user here.

impersonationContext.Undo();
--
smHaig
Nov 19 '05 #1
2 1133
Did you get a compilation error?
Or an exception at runtime? If so, what exception?

Don't forget to disable anonymous auth in IIS and set the auth in your
web.config to Windows.

Nov 19 '05 #2
The error regards the token that I need to set up and further research
indicatated that to set up an anonoymous account was very complicated.

What do you mean by set the auth in the config?
--
smHaig
"Stefan" wrote:
Did you get a compilation error?
Or an exception at runtime? If so, what exception?

Don't forget to disable anonymous auth in IIS and set the auth in your
web.config to Windows.

Nov 19 '05 #3

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

Similar topics

9
by: Ben Dewey | last post by:
Project: ---------------------------- I am creating a HTTPS File Transfer App using ASP.NET and C#. I am utilizing ActiveDirectory and windows security to manage the permissions. Why reinvent...
12
by: Anil Krishnamurthy | last post by:
We have an ASP.NET application that uses COM objects through Interop. The web application requires access to network and database resources and hence, needs to impersonate a domain account. The...
1
by: techfuzz | last post by:
I'm posting my problem experience and solution I found here for other ASP.NET developers. I have a web application that uses Forms Authentication with Active Directory to control access. In...
3
by: cjk | last post by:
Issue Our web application requires access to write to a custom event log, yet access is denied. This access is denied because we are using impersonation, and our end-users do not (should not) have...
7
by: Bonj | last post by:
Hi I made a naff web application which uses the impersonation method in MSDN (can't find it now, but it basically revolves around creating a token by calling the LogonUser API, calling...
3
by: Jake Smythe | last post by:
Hello, I have some code that impersonates a user upon launching of the application. We now have the need to run some command line items. The impersonation doesn't seem to pass to the commands...
1
by: Patrick | last post by:
I have an ASP.NET web service whose Web.Config is set to use impersonation <authentication mode="Windows" /> <identity impersonate="true" /> Within a Web Method, I want to use...
3
by: Carl | last post by:
Using VB .NET how can I enable my program to access a share on another machine and pass the user name and password. I have a computer and share, say "\\computer\share" so I can copy files from it...
0
by: velvet.graham | last post by:
I'm having a difficult time with impersonation. I've created an impersonation class. Here is the code below: ******Impersonation Class Code********* Imports System Imports System.Web.Security...
0
by: khubieb | last post by:
Simply I am trying to use RSACryptoServiceProvider to generate a key pair, send the public key to a service that will retrieve me data, encrypt it with my public key, send the encrypted data back...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.