?
Solved

Get a user's logon id from javascript

Posted on 2003-03-24
26
Medium Priority
?
270 Views
Last Modified: 2008-02-01
Hey all,
Damn, I signed up because I wanted an answer, and I can't friggin search (without paying for it, anyway)!!

I'm not scrolling through 18000 questions to see if one is related to mine (and yes, I did google for this first).

The closest thing I found was this (for PERL)
http://www.experts-exchange.com/Programming/Programming_Languages/Perl/Q_20037058.html

Can I do something similar with Javascript.
See, I'm working on a web-site which will only be on the intranet.  I would like to be able to get the user's logon id from WinNT (or anywhere if there is a more cross-platform solution).

Thanks for any help everyone,
Radish21
0
Comment
Question by:Radish21
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 13
  • 6
  • 4
  • +1
26 Comments
 

Author Comment

by:Radish21
ID: 8199194
Damn it, this always happens.  I (finally) found something more relevant here:
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20467492.html

So, is that the accepted way?  Can't be done??

That sucks....
0
 
LVL 4

Expert Comment

by:whammy
ID: 8199554
Can you use ASP/VBScript? I know you can use VBScript since you're on an intranet... but for a website you would have to have IIS installed on the server (not a biggie if you're using a Windows platform).

P.S. Chill out man! ;-)

0
 

Author Comment

by:Radish21
ID: 8199728
Mate, I don't even know what ASP stands for (or IIS for that matter).  I know ABSOLUTELY nothing about any of those.  I'm a work-experience (uni) student, out of my field.

I was just wondering if there was a nice, easy Javascript command to do it (I know Java, and Javascript isn't too different, plus I was already using Javascript for a feedback form).

I wouldn't have a clue what the web-server is running.  The web-master won't return my emails :)

Anyway, I think the concensus is that it can't be done with javascript, and although it can be done, it's not easy.

Thanks for the reply anyway.

Cheers,
Radish21
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 10

Accepted Solution

by:
m8rix earned 100 total points
ID: 8200030
Radish21 It definatly cannot be done using Javascript.

May be possible using ASP (Active Server Pages) or JSP (JavaServer Pages) or various other Server side scripting.

Reg's
0
 

Author Comment

by:Radish21
ID: 8200079
Bit hard to rate a question as excellent when it tells you that you can't do something.  But hey, it couldn't really have been more truthful, huh?
0
 
LVL 10

Expert Comment

by:m8rix
ID: 8200103
Beleive me... I know how you feel ;)
0
 
LVL 6

Expert Comment

by:ije
ID: 8200579
Radish mate, I know exactly how you feel.

Javascript can't get the user's logon id itself - but it can be used with Window's Script Host to get it (if it's installed). Give this code a go - if it works, it's installed and it works - if not - haven't lost anything.

Just cut all this code, then open it up to see if you userid shows up:
_________________________________________________________

<html>
<head>
<script>
var WSHNetwork  = new ActiveXObject("WScript.Network");
var UserName = WSHNetwork.UserName;
</script>
</head>
<body>
<script>
document.write(UserName)
</script>
</body>
</html>
__________________________________________________________

P.S. You've gotta be an Australian ;)
0
 

Author Comment

by:Radish21
ID: 8206116
I got back undefined.  Thanks for the try though.

Bloody oath I'm a dinky-di aussie, true-blue through and through mate!

It's the starting off sentences with Mate, isn't it?

ije I would have picked you as one too, except you say Australian rather than aussie... perhaps you've been here a few times?  Learnt the lingo?
0
 
LVL 6

Expert Comment

by:ije
ID: 8206266
I'm an Aussie (from the country - stuck in Melbourne)- I try to use 'proper English' in these sorts of places cause you could be dealing with people that have a pretty good idea about JavaScript and stuff, but have a hard time figuring out what I'm saying....

Anyway - one thing I don't like about this place is when people just say "can't be done" - if there's a possible way to do it - explain it!

Give this a go:

Cut the code below, stick it in a page, and save it as "username.asp", not as "username.htm". And when you open the file, you HAVE to open it via "http://....", you can't just double-click on it in Windows Explorer (So the address can't be "C:/my documents/.....".
__________________________________________________________

<%@ LANGUAGE="VBSCRIPT" %>
<html>
<head>
<title>ASP User ID</title>
</head>
<body>
<%

'--- Get User LAN ID ---
Dim UserDomainLAN
    UserDomainLAN = UCase(Request.ServerVariables("LOGON_USER"))
If Len(UserDomainLAN) = 0 Then
    sValues = Request.ServerVariables("REMOTE_ADDR")
End If

%>
<%=UserDomainLAN%>
</body>
</html>
__________________________________________________________

Cheers
0
 

Author Comment

by:Radish21
ID: 8206501
So it actually has to be loaded from the web, not locally eh?  Well, may take me a while to organise that test... The plan was that I make the web locally, and when it's finished, then put it on the server...

Thanks again for the help, love coming across these friendly forums.

Yeah, I'm from Melbourne, but I'm stuck in Sydney at the moment ;)
I'm around the Dandenongs, yourself?
0
 
LVL 4

Expert Comment

by:whammy
ID: 8206891
Cool, nice to see an Aussie on the forums. I hope to visit Australia one of these days.

Aussies are probably more like Americans (except that most Aussies I've met seem more fun loving and friendlier in general) than any other people I know of.

Besides, I love the desert - I plan on spending a good part of my time there if I ever get to go in the Outback. ;-)

Hope you get that WSH or ASP solution working, m8.
0
 
LVL 10

Expert Comment

by:m8rix
ID: 8206961
Mate... I didn't realise there were so many fellow Aussies here...

I am also Aussie... I live in Melbourne too! I am from the Knox area (Sth/Est Suburbs)
0
 

Author Comment

by:Radish21
ID: 8206999
Yeah, I hope I get it working too ;)  Bloody web-master takes his time responding to my emails though, all I want is for him to create a directory for me, and give me permission!

Oh yeah, being laid back and having fun is the aussie motto (along with drinking beer and watching sport, but I think that's universal)!

What is it that you like about the desert?  Just a lot of red sand, with snakes everywhere....  Apart from the bloody great rock sticking out of the middle of our country....
But yes, I understand, it can be very beautiful out there.
I quite like the forests, a lot of that in Dandenongs (Victoria).

BTW, what do the Ops think of off-topic conversations?  I've been posting on the Java forums a lot, and every now and then a thread gets shut down.... A bit antisocial of them I think.
0
 
LVL 6

Expert Comment

by:ije
ID: 8207006
Looks like there's heaps of us!
I'm in Ascot Vale, but working in Sth Melb.

Wonder if there's any Indians here that wanna talk about cricket?
0
 

Author Comment

by:Radish21
ID: 8207010
>m8rix from Knox??  I'm from Upwey, right next to Belgrave!

What do you think of this new 0-zone?  Too many posh bars (bar bosh ;) and clothes shops.  A few cool stores inside though.  The Vmax is pretty cool too...
0
 
LVL 4

Expert Comment

by:whammy
ID: 8207020
Not sure, but I had to say hi to a friendly Aussie (sorry if it's off topic!).

My Dad has some great war stories about Aussies he fought with in Vietnam. ;-)
0
 

Author Comment

by:Radish21
ID: 8207028
>m8rix from Knox??  I'm from Upwey, right next to Belgrave!

What do you think of this new 0-zone?  Too many posh bars (bar bosh ;) and clothes shops.  A few cool stores inside though.  The Vmax is pretty cool too...
0
 

Author Comment

by:Radish21
ID: 8207033
> Not sure, but I had to say hi to a friendly Aussie (sorry if it's off topic!).

I didn't mean OP as in me, but anyone who monitors these.  

I quite enjoy these off-topic conversations.  So, which country are you from whammy?
0
 

Author Comment

by:Radish21
ID: 8207039
> Not sure, but I had to say hi to a friendly Aussie (sorry if it's off topic!).

I didn't mean OP as in me, but anyone who monitors these.  

I quite enjoy these off-topic conversations.  So, which country are you from whammy?
0
 
LVL 4

Expert Comment

by:whammy
ID: 8207048
The United States of America. ;-)

I don't know about everyone else, but I consider your country a great ally of ours, I like the people, and I think you've also fought alongside us in every war in recent (or not so recent) history - regardless of its popularity.

Not that that matters, but I just like the overall attitude of Aussies. If I was to live anywhere else in the world (and I may, someday) it would be in Australia.
0
 

Author Comment

by:Radish21
ID: 8207049
> Not sure, but I had to say hi to a friendly Aussie (sorry if it's off topic!).

I didn't mean OP as in me, but anyone who monitors these.  

I quite enjoy these off-topic conversations.  So, which country are you from whammy?
0
 

Author Comment

by:Radish21
ID: 8207057
> Not sure, but I had to say hi to a friendly Aussie (sorry if it's off topic!).

I didn't mean OP as in me, but anyone who monitors these.  

I quite enjoy these off-topic conversations.  So, which country are you from whammy?
0
 
LVL 4

Expert Comment

by:whammy
ID: 8207058
Ahh!!! If you don't want to refresh the page, click the "reload this question" button. ;-)

It's a bug in EE, hopefully they will fix it long with all of the experts here. ;-)
0
 
LVL 4

Expert Comment

by:whammy
ID: 8207063
I mean, click the link "Reload the question" at the upper left hand corner of the page.

And hopefully they will fix it "before" long. ;-)
0
 

Author Comment

by:Radish21
ID: 8207070
God almight, this post just keeps on appearing!!

Must be because I was clicking refresh to get the latest message....
Sorry all.

Is there another way of getting the latest messages, rather than having to open the notification email?  (I'm sure there would be, I'm asking what is it? ;)
0
 
LVL 10

Expert Comment

by:m8rix
ID: 8207148
Yeah I've been to o-zone a few times.. I went to go to the Irish pub there in the first week and we ended up waiting in a que for an hour so we ended up going to the trusty Q-sportz...

Anyway I don't mind some of the new shops... Bar world is pretty nifty!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question