...

View Full Version : how to get client's username,computername,domain name using asp/javascript



Rashmir
01-05-2005, 07:01 AM
Hi All,
Can any of you please tell me how to get client's username,computername,domain name using asp/javascript.we don't want to change any setting on IIS that is it will have anymonous access.I tried with server varaibles and Window script host.I don't want any client to install Activex,So can any please help regarding this.

Thanks in advance,
Looking forward for reply,

Regards,
Rashmi

miranda
01-05-2005, 07:36 AM
built in security prevents this

Rashmir
01-05-2005, 08:13 AM
ok,

Can it be done in any other way using javascript or some other language?
Can I just by any means get required information and pass it on to server?

Regards,
Rashmi

glenngv
01-05-2005, 09:24 AM
Is this for intranet? I know an ASP component that can execute DOS commands from the server. You can execute a DOS command in the server where you can derive the PC name, username and domain of the user in the network.

Rashmir
01-05-2005, 09:33 AM
Hi,
Actually the site is internal use only,only employee of the company can access it,can you please given me more information on what you have said,some example will be very much appreciated or you can give the link of the article where can I found more about running dos comands from asp.


Thanks and Regards,
Rashmi

glenngv
01-05-2005, 10:36 AM
AspExec (http://www.serverobjects.com/products.htm#free)

Rashmir
01-05-2005, 10:51 AM
ok how can I get username,computername and domain using dos comands through aspExec asp component

Thanks and Regards,
Rashmi

glenngv
01-05-2005, 11:10 AM
ok how can I get username,computername and domain using dos comands through aspExec asp component

Thanks and Regards,
Rashmi
Execute nbtstat -a IPaddress and then from the output, you can parse the needed data. Try to execute that first in the DOS console to see what the output looks like.

Rashmir
01-05-2005, 11:17 AM
Even if I use this component it will execute on server computer right,I want client's username,clients computer name & clients domain name.

is their no way I can get Client information?

Thanks and Regards,
Rashmi

glenngv
01-05-2005, 11:48 AM
You specify the IP address of a remote machine in the network.

nbtstat -a IPaddressOfRemoteMachine

Try executing that in the DOS console and you will see the NetBIOS information of the remote machine.

Rashmir
01-05-2005, 12:17 PM
It displays all the list of user but how I will be able to figure out who had logged in,I want the current user name.

Thanks and Regards
Rashmi

glenngv
01-05-2005, 01:00 PM
I know that's an awkward way of finding the user's machine information. Probably there's a better way of retrieving them.

But let's deal with this...
The list consists of username, domain and pc name. As you can see from the list, there is a Type column that says UNIQUE or GROUP. There is also a number like this <##>, e. g. <00>. Use those 2 data to determine the pattern that tells which of them are username, domain and pc name.

Rashmir
01-05-2005, 01:21 PM
I am using Remote_addr servervariables to get the IP address,but its not diplaying the current IP address and moreover I am access the site through VPN access and I am getting still the server machine information instead of client information.Even I try with same domain it display all user with <##> but their r 3 to 4 entries with number so how I will be able to recongnize who as logged in

glenngv
01-05-2005, 01:46 PM
Can you post a sample output here? Of course, you need to change some sensitive data to bogus ones.

Rashmir
01-05-2005, 02:07 PM
The code I have written is as follows

<html>
<head><title>ASPExec Test (copy)</title><head>
<body>
<H3>ASPExec Copy Test</H3>

<%
Set Executor = Server.CreateObject("ASPExec.Execute")
dim str
str=request.ServerVariables("REMOTE_ADDr")
str="-A " + str


Executor.Application = "cmd /c nbtstat"
Executor.Parameters = str
strResult = Executor.ExecuteDosApp
Response.Write "<pre>" & strResult & "</pre>"

%>

</body>
</html>

and the result output is as follows

Local Area Connection:
Node IpAddress: [16.105.79.104] Scope Id: []



NetBIOS Remote Machine Name Table



Name Type Status

---------------------------------------------

CACCTSDEV02A <1F> UNIQUE Registered

CACCTSDEV02A <00> UNIQUE Registered

AMERICAS <00> GROUP Registered

CACCTSDEV02A <03> UNIQUE Registered

CACCTSDEV02A <20> UNIQUE Registered

INet~Services <1C> GROUP Registered

IS~CACCTSDEV02A<00> UNIQUE Registered



MAC Address = 00-0B-CD-F2-98-81


So as it is displaying domain names instead of local name,how can I figure out current user

glenngv
01-05-2005, 02:24 PM
Look at <03> UNIQUE. If the corresponding name is a PC name, you can assume that the user is logged on as Administrator, otherwise, it is the username. The domain is the one that has <00> GROUP.

Rashmir
01-05-2005, 02:42 PM
ok but its displaying domain names and not local user name,I want the username for doing further verfication,how to get the username and domain name both.

Thanks and Regards,
Rashmi

glenngv
01-06-2005, 02:48 AM
Isn't CACCTSDEV02A the computer name and not domain name?
And isn't AMERICAS the domain name?

Anyway, try this code. I dug up my old code and modified it a bit.


ip = request.ServerVariables("REMOTE_ADDR")
defaultusername="ADMINISTRATOR"
compname="<unknown>"
logdomain="<unknown>"
domainname="<unknown>"

Set Executor = Server.CreateObject("ASPExec.Execute")
Executor.Application = "cmd /c nbtstat"
Executor.Parameters = "-A " & ip
Executor.ShowWindow = false
strResult = Executor.ExecuteDosApp
Set Executor = nothing

if instr(1,strResult,"NetBIOS Remote Machine Name Table")>0 then
arrRes = split(strResult,VbCrLf)
ctr=0
for each item in arrRes
lt = instr(1,item,"<")
gt = instr(1,item,">")
if lt>0 and gt>0 then
ctr=ctr+1
name=trim(mid(item,1,lt-1))
num=mid(item,lt+1,2)
nametype=trim(mid(item,gt+1))
if nametype="UNIQUE" and num="00" and compname="<unknown>" and instr(1,name,"~")=0 then compname=name
if nametype="GROUP" and num="00" then domainname=name
if nametype="UNIQUE" and num="03" and compname<>name and instrrev(name,"$")=0 and name<>"NETSHOWSERVICES" and instr(1,name,"_MSBROWSE_")=0 then username=name
end if
next
else
errmsg=strResult
end if

if username="" then
username=defaultusername
logdomain=compname
else
logdomain=domainname
end if

if errmsg<>"" then
response.write "<pre>" & errmsg & "</pre>"
else
response.write "PC Name: " & compname & "<br>"
response.write "Username: " & username & "<br>"
response.write "Domain: " & logdomain & "<br>"
end if

Rashmir
01-06-2005, 07:31 AM
ok fine,I tried you code,it works fine in some system and not in other as in some of the machine the username is not displayed and I don't know why,its displays domain and computer name but not username and for me getting username is very important,do you know whats the problem ?
I pasting my oupput

Name Type Status

---------------------------------------------

120816-2E159 <00> UNIQUE Registered

WORKGROUP <00> GROUP Registered

120816-2E159 <20> UNIQUE Registered

WORKGROUP <1E> GROUP Registered

120816-2E159 <01> UNIQUE Registered

120816-2E159 <03> UNIQUE Registered

you can see that their is no username being displayed generally it will with <03> right?I am not able to figure out why its not displaying username?

Thanks and Regards
Rashmi

glenngv
01-06-2005, 08:18 AM
you can see that their is no username being displayed generally it will with <03> right?I am not able to figure out why its not displaying username?

Thanks and Regards
Rashmi
As I said in my previous post, if <03> contains the PC name instead of the username, the username used is (assumed to be) Administrator. Didn't the script I posted output ADMINISTRATOR as the username? Can you also post the output generated by my script on the output you pasted?

Rashmir
01-06-2005, 08:47 AM
I am not getting,does it mean that if username is not displayed then he has admin rigths.I want username thats very important for me as I have to do further query in a table based on username.Even in some machine when a user has admin rights,their names were displayed and in some machine when you have logged in with some user,then irrespective of rights the username has,their name was not displayed?
Is their any constrain why the username not displayed?getting username and domain name is very important to me,I cannot query with administrator as we don't want any default value so IS their no way I can get username?

Thanks and Regards,
Rashmi

glenngv
01-06-2005, 10:51 AM
If there is no username, the currently logged-in username of the remote machine is the username "Administrator". The domain where the user logged-in could be his own machine or the network domain.

Can you post the output of the script I posted so that I can analyze it?

Rashmir
01-06-2005, 11:44 AM
below is the output of your script

Name Type Status

---------------------------------------------

120816-2E159 <00> UNIQUE Registered

WORKGROUP <00> GROUP Registered

120816-2E159 <20> UNIQUE Registered

WORKGROUP <1E> GROUP Registered

120816-2E159 <01> UNIQUE Registered

120816-2E159 <03> UNIQUE Registered



MAC Address = 00-C0-A8-FF-CC-0A


PC Name: 120816-2E159
Username: ADMINISTRATOR
Domain: 120816-2E159

as we can see its not displaying the username and my friend has logged into his machine with his name and not as adminstrator and I want the logged user name and I am still wondering why its not displaying username.We are on same domain and still not getting the username,can u figure out why?
Is nbtstat as any restriction or any constrain ?

one more thing if their are 2-3 users in a machine,how I will find out current logged user?


Thanks and Regards
Rashmi

glenngv
01-06-2005, 01:15 PM
Your friend's PC is a member of a Workgroup and not a Domain (but you said the server and his machine are in the same domain?). If that's the case, I don't know if there's any way nbtstat can determine the username used for that machine.

Rashmir
01-06-2005, 02:01 PM
my friend's machine I just tried to get information as I had posted the site in my machine which is also a workgroup.I tried in a machine with domain,where server and client were on same domain,still I didn't got the user info as I had logged into the client machine ,below is the output

NetBIOS Remote Machine Name Table



Name Type Status

---------------------------------------------

ZCAPXYPRO03 <1F> UNIQUE Registered

ZCAPXYPRO03 <00> UNIQUE Registered

AMERICAS <00> GROUP Registered

ZCAPXYPRO03 <03> UNIQUE Registered

ZCAPXYPRO03 <20> UNIQUE Registered

INet~Services <1C> GROUP Registered

IS~ZCAPXYPRO03.<00> UNIQUE Registered

you can see its not displaying the username and I want the username very badly.can I just tell me why it is so?

Thanks and Regards
rashmi

glenngv
01-06-2005, 02:18 PM
my friend's machine I just tried to get information as I had posted the site in my machine which is also a workgroup.I tried in a machine with domain,where server and client were on same domain,still I didn't got the user info as I had logged into the client machine ,below is the output

NetBIOS Remote Machine Name Table



Name Type Status

---------------------------------------------

ZCAPXYPRO03 <1F> UNIQUE Registered

ZCAPXYPRO03 <00> UNIQUE Registered

AMERICAS <00> GROUP Registered

ZCAPXYPRO03 <03> UNIQUE Registered

ZCAPXYPRO03 <20> UNIQUE Registered

INet~Services <1C> GROUP Registered

IS~ZCAPXYPRO03.<00> UNIQUE Registered

you can see its not displaying the username and I want the username very badly.can I just tell me why it is so?

Thanks and Regards
rashmi
And the user is not logged-in as Administrator?

Rashmir
01-06-2005, 02:45 PM
yes user is not logged in as adminstrator,he has logged with his username

zeroxs
06-11-2009, 04:52 AM
yes user is not logged in as adminstrator,he has logged with his username

try dis..
see what u want

For i As Integer = 0 To Request.ServerVariables.Count - 1
Response.Write(Request.ServerVariables.Keys(i) & " : <br /> [ " & Request.ServerVariables(i) & " ] <br /> ")
Next



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum