I don't think javascript/browsers support access to OS JUST TRY IF ACTIVEX Control will help you script language="javascript" type="text/javascript"> var wshell = new ActiveXObject("WScript.Shell"); alert(wshell.ExpandEnvironmentStrings("%USERNAME%"));
var WshNetwork = new ActiveXObject("WScript.Network"); alert(WshNetwork.UserName);
Thanks for the information shared. And also I would like to mention some of my clients are using form Authentication, does it works in such environments. We are planning to host our solution in windows azure environment.
with forms authenication it will work if you use active directory for authenication. for azure, you will need to install a federated service on azure that will proxy back to your active directory.
thanks for the supoort given. and also it was works for me only in IE (after adding the site URL to trusted sites) . firefox, crome, safari it didn't work. and situation like "domain/ ranil","domain/niroshana" it will drop the "/r" and "/n" .
appreciate your consideration for above mentions !
what I really required is to get the windows login user and update in the database when user request the page.
Wickey
Member
105 Points
25 Posts
How to trace windows login user from jQuery
Jul 19, 2012 09:42 AM|LINK
Hi all
Anyone can help me, how to get windows login user through jQuery or Java script. (with out using any activeX)
Thanks
Ranil
shabirhakim1
Star
13496 Points
2145 Posts
Re: How to trace windows login user from jQuery
Jul 19, 2012 01:31 PM|LINK
azhar.rabi
Member
146 Points
26 Posts
Re: How to trace windows login user from jQuery
Jul 19, 2012 02:10 PM|LINK
You can get the windows login user
Step 1 and most important under IIS settings your site must be configuered
"Integrated Windows authentication"
Step 2 add javascript code in head section on a aspx page.
<script type="text/javascript"> function getLogin() { var szLogin = '<%Response.Write(Request.ServerVariables["AUTH_USER"]); %>' var length = szLogin.length; alert(szLogin); return szLogin; } </script>and you are all done
Wickey
Member
105 Points
25 Posts
Re: How to trace windows login user from jQuery
Jul 20, 2012 02:06 AM|LINK
Hi Azhar
Thanks for the information shared. And also I would like to mention some of my clients are using form Authentication, does it works in such environments. We are planning to host our solution in windows azure environment.
Appreciate your feedback on above.
Ranil
bruce (sqlwo...
All-Star
36656 Points
5438 Posts
Re: How to trace windows login user from jQuery
Jul 20, 2012 04:56 AM|LINK
with forms authenication it will work if you use active directory for authenication. for azure, you will need to install a federated service on azure that will proxy back to your active directory.
Magulagama
Member
4 Points
2 Posts
Re: How to trace windows login user from jQuery
Jul 24, 2012 09:45 AM|LINK
Hi Azhar,
I have same issue. I also follow the above steps, but it’s not work. (My web site published in IIS 7.5).
azhar.rabi
Member
146 Points
26 Posts
Re: How to trace windows login user from jQuery
Jul 24, 2012 06:58 PM|LINK
make sure you are doing the right steps on using integrated authentication here are couple of links which will help you to setup the IIS7.5
http://www.iis.net/ConfigReference/system.webServer/security/authentication/windowsAuthentication
http://forums.iis.net/p/1183613/2004604.aspx
Magulagama
Member
4 Points
2 Posts
Re: How to trace windows login user from jQuery
Jul 25, 2012 03:09 AM|LINK
Thanks, It’s work properly
Wickey
Member
105 Points
25 Posts
Re: How to trace windows login user from jQuery
Jul 27, 2012 01:07 AM|LINK
Hi Azhar
thanks for the supoort given. and also it was works for me only in IE (after adding the site URL to trusted sites) . firefox, crome, safari it didn't work. and situation like "domain/ ranil","domain/niroshana" it will drop the "/r" and "/n" .
appreciate your consideration for above mentions !
what I really required is to get the windows login user and update in the database when user request the page.