Help - Search - Members - Calendar
Full Version: %username% in URL possible?
MSFN Forums > Coding, Scripting and Servers > Web Development (HTML, Java, PHP, ASP, XML, etc.)

   
Google Internet Forums Unattended CD/DVD Guide
BodiSnacha
Folks, I am interested in passing an environment variable in a URL. The goal is to automatically log the user in based on who they are logged onto the workstation as without any prompts.

The url will be http://helpdeskserver/caisd/pdmweb.exe?USERNAME=%username%

The web site is developed on IIS with Frontpage. Frontpage doesn't interpret the %username% correctly and passes an argument error.

Can anyone assist?

J (flynnj@sddc.army.mil)
liquidplasmaflow
How about using a Java/VBScript on the page linking to that page, a script that finds the username and appends it to the link?
HyperHacker
You might be able to get away with having the page just ask for their name, perhaps with a password like most do. If not, I'd write a small program which opens the page. GetUserName() will tell you the name, and I think you can use ShellExecute() to open the URL. (I did it once, but I don't recall how and don't feel like checking right now. Pretty sure that was it though. It opens in the user's default browser too.)

If you need to keep track of the name on multiple pages, store it in a cookie or database with an expiration date and have a 'log out' link to clear it. If no name is logged, tell the user to run the program again, and offer a link to it.

There might also be some ActiveX solution, but now you're getting into nasty IE-only stuff.
Rhelic
JavaScript has no way to grab the local users username. But in an Intranet solution with an Active Directory server, you can get the username via ASP and ASP.Net programming, here are my notes on the subject

=================================================
Retrieving the web user's username in a Domain/Intranet for ASP.Net
=================================================

Manage IIS > right Click Web Sites > Properties > Directory Security >
Edit Button (Auth & Access Control) > uncheck 'Enable anonymous access'
and make sure 'Integrated Widows Auth' is check marked

Then if you want the ASP.Net to run as the web user then add this to
your web.config
<identity impersonate="true" />

Now you can access the username by:
HttpContext.Current.User.Identity.Name;

using System.Security.Principal;
System.Threading.Thread.CurrentPrincipal.Identity.Name;


or in classic ASP:
Request.ServerVariables("LOGON_USER")

-----------------------

If your app is not ASP or ASP.Net you're probably screwed but I haven't used PHP, Cold Fusion or Perl for years and perhaps there is a way now.
Google Internet Forums Unattended CD/DVD Guide
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.