![]() |
|
|
| Subject:
Get the windows login username
Category: Computers > Programming Asked by: darrensmith-ga List Price: $50.00 |
Posted:
01 Jul 2002 04:38 PDT
Expires: 31 Jul 2002 04:38 PDT Question ID: 35422 |
I am constructing a simple html form. One of the fields on the form will be the Name of the person currently accessing that form. I would like to populate this field automatically by extracting the Username and surname from the microsoft domain server that the user has logged into. what is the script needed to do this? | |
| |
| |
| |
| |
| |
|
|
| There is no answer at this time. |
|
| Subject:
Re: Get the windows login username
From: iaint-ga on 01 Jul 2002 05:59 PDT |
I suspect this is going to be an impossible task, for the simple reason that it would break Javascript's security model. The user's name and domain are automatically set as environment variables in Windows NT and Windows 2000 http://support.microsoft.com/default.aspx?scid=kb;EN-US;q100843 -- however if the browser had read ability to such information then it could pass potentially private data back to a server without the user being aware of it. To prevent this kind of thing, Javascript (or any other browser scripting language) is unable to read client system environment variables. iaint-ga |
| Subject:
Re: Get the windows login username
From: gopalkamat-ga on 01 Jul 2002 06:03 PDT |
Hi darrensmith-ga, As far as my knowledge and research goes regarding HTML, Javascript or even Server-side Scripting languages, I can say that it is not possible to extract the NT domain login name for any particular user over the web. This, because it would be considered a serious security breach to allow this to happen. The only way I think this would be possible is if the code in your form (mostly Javascript, I think) was to explore any hacks/exploits discovered in the browser software (IE or Netscape)... but even as I say this, I know that both these browsers have come a long way to allow for such hacks/exploits in the code. Once again, what you're seeking is not possible in today's world. If tomorrow, IE or Netscape released a new version of the browsers with a hack/exploit in them, then this may be remotely possible. Hope this helps you out... regards, gopalkamat-ga |
| Subject:
Re: Get the windows login username
From: netcrazy-ga on 01 Jul 2002 06:22 PDT |
I agree with both the above comments. As of today, getting the details from client's system using Javascript is not possible. You'll need to make some changes either in your html page to ask the user to enter the name or something else you'll have to think.... Thanks netcrazy |
| Subject:
Re: Get the windows login username
From: pboy-ga on 01 Jul 2002 06:35 PDT |
I agree with all the comments above, it is not possible with a
client-side script.
If you create the HTML form from a server-side script and the server
uses IIS NT authentication ('Integrated Windows Autentication'), you
will get the user name in the AUTH_USER enviroment variable on the
server-side. An ASP or PHP script can insert this user name into the
form generated.
Getting other user information (like real world name) require to
develop a small OLE object in a Win32 native language, e.g. Delphi,
VB, C++.
On client-side, it _may_ be possible with an signed ActiveX control,
but I'm not sure and it is also browser-dependant.
regards,
pboy-ga |
| Subject:
Re: Get the windows login username
From: pboy-ga on 01 Jul 2002 06:38 PDT |
Just a little correction on my comment: On server-side, you don't need to develop an OLE object. ADSI can be used from ASP. |
| Subject:
Re: Get the windows login username
From: wengland-ga on 01 Jul 2002 06:51 PDT |
Acutally, with IE it may be possible - you'll need a signed fully trusted script or Active X control. No idea how to write that, but it's one tangent you may want to look at. |
| Subject:
Re: Get the windows login username
From: vit-ga on 01 Jul 2002 11:25 PDT |
Hello, The best way to do that will be using VB Script.. The reason is that VB Script is the best to invoke internal controls of Windows OS....I don't really know how to do that but I can do it using API in Visual Basic. The API call needed can be declared as under : Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long But I don't know how you will incorporate this in VB Script. Hope this information may help you in some way or the other. But mind you, how will you get the username of any person surfing your site through a MAC or UNIX OS???? Warm Regards, VIT (Vivek Toshniwal) |
| Subject:
Re: Get the windows login username
From: robbienewbie-ga on 01 Jul 2002 13:21 PDT |
Supporting VIT's comment, you can work with VBScript and VB. Just create a VisualBasic program that able to see username. When it works, move it as OCX, which should be usable within VBScript/HTML. This way, instead of finding a way to pass HTML/Scripting limitation, you just need to focus on VisualBasic programming to access those data. |
| Subject:
Re: Get the windows login username
From: webbob-ga on 01 Jul 2002 21:52 PDT |
This all sounds like a lot of ways to gain something that should not (would not) be gained if it was directed at you the answers' team. I think everyone should rethink where they are coming from on this one. Besides, there is no way you can get the users name, if it does not exist on their computer. Even if you do get a users name, it may be an alias. Dont you think, by now, people are sophisticated enough to understand that there is a computer world and there is a real world? Who are you trying to kid? webbob-ga |
| Subject:
Re: Get the windows login username
From: pboy-ga on 02 Jul 2002 00:54 PDT |
If you accept as answer, I can give you an ASP example in JScript or VBScript (tested, working). My solution works only on the server-side (the form must be generated from ASP code), if IIS use Integration Windows Authentication (automatically handled by Internet Explorer) and no client certificates applied to the corporate intranet site. Retrieving the surname from the user's real name is a little bit complex task, since no difference is made between first and last names (AFAIK). If you have a corporate policy for real word user names (e.g. "Peter, Falk"), surname extraction can be done easily. |
| Subject:
Re: Get the windows login username
From: pboy-ga on 10 Jul 2002 05:35 PDT |
Is there a real reason to write an OLE object to retrieve the full user name on server side (ASP) in Windows 2000? If I understand the circumstaces right, a WMI query can return it from two lines of ASP code (if you already have the domain user name from AUTH_USER or LOGON_USER). I already had it working on our intranet, just some lines of JScript ASP code. |
| Subject:
Re: Get the windows login username
From: pboy-ga on 10 Jul 2002 05:45 PDT |
Errata: "WMI" should be read as "ADSI". Pardon :) |
| Subject:
Re: Get the windows login username
From: mileshelp-ga on 16 Jul 2002 11:00 PDT |
Hi, Since your servers are running Windows 2K, this makes things quite a bit easier. Active Directory within Win2K is basically an LDAP database, so can be queried for the additional information in a similar method. I'm just trying to put together some sample source to demonstrate this and will hopefully post it later today. Hope this helps, Miles. |
| Subject:
Re: Get the windows login username
From: nymsdeveloper-ga on 16 Jul 2002 19:52 PDT |
Hi SCRIPT FOR your question
here is a simple page. actually intstead of WinNT(LDAP) ADSI can be
used if available. We do a automatica login in our intranet
application for domain users. discussions here are way off... people
never understood what you were talking about
jai 917 496 4115
<%@ Language=VBScript %>
<HTML>
<HEAD>
<title>Full User name</title>
</HEAD>
<BODY>
<%
dim strUser ,objUser , sDomain , iPos
strUser = trim(Request.ServerVariables ("LOGON_USER"))
if len(strUser) = 0 then
Response.Write "Unable to find the Login Name. May be not logged to
domain."
Response.End
End if
Response.write "Login Name:" & strUser
iPos = InStr(strUser, "\")
sDomain = Left(strUser, iPos - 1)
sUser = Mid(strUser, iPos + 1)
Set objUser = GetObject("WinNT://" & sDomain & "/" & sUser)
%>
<p>
Welcome <%=objUser.FullName%>
</p>
<%
set objUser = nothing
%>
</BODY>
</HTML> |
| Subject:
Re: Get the windows login username
From: helium-ga on 17 Jul 2002 17:12 PDT |
Well, I was about to suggest using ADSI, but it looks like "nymsdeveloper" has it all wrapped up -- that code will work. Getting the user's logon information on a corporate Windows intranet is a common problem and is easy to solve with Active Directory. If you need some further documentation, the following page is a good resource to what you can do with Active Directory and IIS ... "Add to Your ADSI Code Library" (see Section 4.1 for user's full name) http://www.15seconds.com/issue/020130.htm Good luck! |
| Subject:
Re: Get the windows login username
From: nymsdeveloper-ga on 19 Jul 2002 07:04 PDT |
thank you very much. I am not registered as a researcher, so dont worry abt payment( i dont think i will get it even if u pay...). if you need any other help, let me know. my email is jai@landmark-technologies.com take care nymsdeveloper |
| Subject:
Re: Get the windows login username
From: pboy-ga on 29 Jul 2002 03:17 PDT |
Khm... I have posted the comment about the ADSI solution 6 days before nymsdeveloper-ga posted his/her comment and I also had a working script example. See my comments in the thread. If you'd listen you'd have the code six days before but you know... :) |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
| Search Google Answers for |
| Google Home - Answers FAQ - Terms of Service - Privacy Policy |