Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes HTML, CSS and JavaScript and the fly likes Logged in windows username using ActiveXObject Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Logged in windows username using ActiveXObject" Watch "Logged in windows username using ActiveXObject" New topic
Author

Logged in windows username using ActiveXObject

bikkie bansal
Greenhorn

Joined: Oct 14, 2008
Posts: 17
Hello All,

I trying to get logged in windows username using javascript.
I found this piece of code from some forum.



This code is working fine when I run from my local directory. But when I deploy it in IIS server I am getting error message "Automation server can't create object".
Do I have to do some setting in IIS server?

Thanks in advance.
Bikkie
Nikhil Padharia
Ranch Hand

Joined: Apr 19, 2012
Posts: 37
Try using this code, I am not sure if it will work in all scenarios, as I too found it from some forum ;)


Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
"Automation server can't create object" is the error thrown when Active X Security settings are turned on high and prevent certain things from running. Your local site is under intranet or trusted settings which has different security settings.

There is no way in JavaScript to change the setting, user has to do it manually either changing it for the zone OR adding your site to trusted domains list.

Eric
bikkie bansal
Greenhorn

Joined: Oct 14, 2008
Posts: 17
Hi Eric,

Thanks for your reply. When I changed my local intranet setting from "medium high" to "low" its working fine.
But we cant force client to change their local intranet setting so is there any other way to get username. By doing some googling I found we can use applets or signed jars. I tried applets also but when I used applet I got security permission exception.

Please suggest any solution using which I can get username in my HTML page.

Thanks,
Bikkie
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
There is nothing to do but change settings and by using activeX, you are locking yourself into an IE only solution which is horrible. Coding like that is why companies are still stuck on IE6.

If this app is to be run on an intranet, there are ways you can get the login there. If it is a we app, you are out of luck.
bikkie bansal
Greenhorn

Joined: Oct 14, 2008
Posts: 17
Hi Eric,

This application will be used within intranet only for limited number of users.

Please suggest solution to get username. I am using HTML for UI, IIS 7.5 web server and WCF RESTful web services at backend.

Thanks,
Bikkie
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Using LDAP?
bikkie bansal
Greenhorn

Joined: Oct 14, 2008
Posts: 17
Hi Eric,

I tell you my use case.
User will login into his/her desktop/system though his/her windows credentials which will get validate against LDAP.
Once user successfully logged-in and try to access our application, HTML page should read his/her windows username from NTLM and pass it to authorization service of our application.
If user is successfully logged-in then he/she should not prompt for login again only he/she should be check for authorization only.

This is the our use case.
So i need only logged in person's username.

Thanks,
Bikkie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Logged in windows username using ActiveXObject
 
Similar Threads
calling a ActiveX Object from JSP
Error while invoking SAPI with Java Script
Automation Server Cannot Create Object
calling (VB)activex object from JSP
Popup not working properly on new server