• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How to get username from Win2K

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Does anyone know if it is possible to get the clients win2k username from Tomcat?
And if so, how?
/Emil
 
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
disclaimer:
What I'm posting definitely rates a 10 out of 10 on the skank'o'meter.
It will only work under IE, and it pops up with a warning message.
Due to security restrictions, applets/JavaScript etc are not supposed to be able to access the currently logged in user's name, but for your enjoyment here is some code that does...

note: change "on-Load" to "onLoad", "on-Click" to "onClick"
 
Emil Karlsson
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your help James
But that didn't work on my PC. It said Automation-Server can't create an object.Have any idea, what is wrong?
On the other hand, that was not exactly what I was looking for.
What I want, is that Tomcat (if its possible) can get the user that has a certain session on the webserver and be able to get the Win2K username, for an automatic login to an JSP/JavaBean/SAS-Software applikation. In other words, only the user that can be found in a SAS dataset and that the login get a match with the win2k username are granted login.
/Emil
 
James Swan
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Emil,
I was using win2k, IE6.0.
Can you run regedit and see if you have this entry:
HKEY_CLASSES_ROOT\WinNTSystemInfo
Also to note, my userprofile is in the "Administrators" group.
Also, the flow I imagined (assuming you could get the win2k username) is:
1) include that html code somewhere on a page that submits info back to your appserver, for example you could include that on your regular login page etc
2) save the win2k username in a session for that user
3) ...

Failing that, the only other alternative would be to look into "signed applets", the issue with regular applets is that they don't have permission to read certain properties, in particular "user.name", with signing the applet you could bypass that restriction.
The flow would be similar to what I mentioned above:
1) load page with applet
2) applet retrieves username
3) javascript queries applet for username, copies value to hidden form field
4) ...etc
you can read up on signing applets here
http://java.sun.com/security/signExample12/
http://java.sun.com/docs/books/tutorial/security1.2/tour1/index.html
and some basic code to show applet/javascript interaction
(note, this applet is not signed, so you get a security exception when running it).
(applet)

(html)

note: on-click should be changed to onClick
Compile to applet using javac and run the html page from same directory as compiled class.
[ October 01, 2003: Message edited by: James Swan ]
 
I can't beleive you just said that. Now I need to calm down with this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic