Topic Options
Rate This Topic
#129892 - 01/18/06 06:57 AM Weird Javascript problem trying to obtain Windows UID
wrentfrow Offline
journeyman

Registered: 03/11/04
Posts: 126
Loc: Minneapolis, MN
I am using this bit of Javascript in the mid-tier to capture the User ID:



function envRemoteUserDomain() {
var returnvalue = "<%=request.getRemoteUser()%>";
}

This returns the following value in this environment:

DOMAINuser

It's easy to process that and get the User ID - the problem is sometimes - for no known reason - the value returned has some weird control character in place of the first character in the user name. For example, my user ID "bill" might come back as:

DOMAIN?ill

Any ideas?



William Rentfrow
Principal Consultant, StrataCom Inc.
wrentfrow@stratacominc.com
http://www.stratacominc.com
952-432-0227 Office
701-306-6157 Cell


Top
#129893 - 01/31/06 12:09 AM Weird Javascript problem trying to obtain Windows UID [Re: maryann_armitage]
jbaker800 Offline
newbie

Registered: 01/03/06
Posts: 30
William,

Imagine the string returned is this:

XXX\bbb

You can't just throw this into a JS string without encoding it. Put this into
your browser URL bar:

javascript:alert('XXX\bbb')

Now put this in it:

javascript:alert('XXX\bbb')

So what I'd do is:

function envRemoteUserDomain() {
var returnvalue = "<%= request.getRemoteUser().replaceAll("\\", "\\\\")
%>";
}

(I haven't tested that.)

Which will turn \ into \\ (even though you can see \\ and \\\\, given you
can't just put \ into a Java string without encoding it).

Although, I wouldn't do it quite like that given it's not always going to work
(request.getRemoteUser() can quite happily return null). What you need to do
is find the posting I made on this topic sometime before Christmas, perhaps
in October or November.


John

Java System Solutions : http://www.javasystemsolutions.com


UNSUBSCRIBE or access ARSlist Archives at http://www.ARSLIST.org

Top