473,659 Members | 2,526 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Programatically Determine IIS User Account?

controlbox
6 New Member
Does anyone know a way to programatically determine the Windows Account IIS is using from inside an ASP or ASP.Net page?
May 3 '07 #1
4 2514
elmemo
30 New Member
Hi,

At work I have used System.Security .Pricipal.Windo wsIdentity.GetC urrent()

Remember though that the identity of secondary processes (say, those who use foreign dll's) might not have the same permissions as the original process acount, this is especially a recurring issue when dealing with network resources.

You can enable impersonation of other user accounts if you need to. (refer to http://www.eggheadcafe .com/articles/20050703.asp )

An excerpt from http://www.eggheadcafe .com/articles/20050703.asp is a good read:

Determining Identity
To determine the identity used for the request I set up a single aspx page that writes out the three most common ways of getting the current identity from a web application. These are the Page.User.Ident ity, System.Security .Pricipal.Windo wsIdentity.GetC urrent() and system.Threadin g.Thread.Curren tPrincipal.Iden tity. The code for the Page_Load event is displayed in Listing 1. The IIS Security Settings dialog can be seen in Figure 1. This displays the options available for configuring web security with IIS.
Listing 1.


private void Page_Load(objec t sender, System.EventArg s e)
{
lblUser.Text = Page.User.Ident ity.Name;
lblWindow.Text = System.Security .Principal.Wind owsIdentity.Get Current().Name;
lblThread.Text = System.Threadin g.Thread.Curren tPrincipal.Iden tity.Name;
}
May 4 '07 #2
controlbox
6 New Member
Many Thanks for the .Net solution. Do you know of a classic ASP solution?
May 4 '07 #3
elmemo
30 New Member
Sorry, I'm a classic asp newbie!
May 4 '07 #4
jhardman
3,406 Recognized Expert Specialist
Does anyone know a way to programatically determine the Windows Account IIS is using from inside an ASP or ASP.Net page?
If no one is logged on I think it is just <i_usr>, although I may have spelled it wrong. It may be in the server variables, try

request.serverV ariables("logon _user")
or
request.serverV ariables("auth_ user")

But I think those will be blank unless you require a logon, in which case IIS is using I_USER

Jared
May 5 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5404
by: RWC | last post by:
Hi Folks, I'm looking for a way to determine if the client machine has access installed and if so, what version. The reason I need this is to determine (programatically) if the Access Runtime is required to be installed and if not, which version of the program database needs to be installed with the current version of Access. (hope that makes sense). If anyonoe could point me in the right direction, I'd really appreciate it.
2
1809
by: RWC | last post by:
Hi Folks, I'm looking for a way to determine if the client machine has access installed and if so, what version. The reason I need this is to determine (programatically) if the Access Runtime is required to be installed and if not, which version of the program database needs to be installed with the current version of Access. (hope that makes sense). If anyonoe could point me in the right direction, I'd really appreciate it.
3
2526
by: dave | last post by:
How do I programatically determine the enabled or disabled status of AD accounts? I have queried the userAccountControl key, but all I get back is an int, and it seems to be the same for enabled or disabled accounts. Please help. I have read the following article: http://msdn.microsoft.com/library/default.asp?
0
928
by: WizyDig | last post by:
Has anyone added a user account to a nonActive directory win2k system programatically? I'm guessing i would need to use the Win32 api but am unsure which functions would be needed to do this. Searches of MSDN have fallen sort. Thanks in advance, Wiz *** Sent via Developersdex http://www.developersdex.com ***
0
8428
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8630
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6181
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4342
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2759
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.