theravada_maha
asked on
nbtstat - multiple login problems
We've made a PHP page that runs the command nbtstat -A [IP number] and grabs the results, sorts through them and finds the user's login name for that IP accessing the php page. Here's the code for your information, it works fine:
function GetLoginName ($IP) {
exec("nbtstat -A $IP",$Lines);
$Lines = KeepIf($Lines, "LineIsUser");
$Lines = ArrMap ($Lines, "BeforeFirstSpace");
$Lines = KeepIf($Lines, "Alphabetical");
return $Lines[0];
}
But we ran into a problem. If I log into my machine and the machine next to me with the same username, problems arise. If I run nbtstat on the machine on which I logged in last, I can't find a username in the list, only the domain name and the computer name. So this obviously isn't good since people are going to access this page and will have to be sure they logged off other machines. I want nbtstat to always return the user's login name, but right now it doesn't seem possible.
Is there any way around this? What can be done?
Eric
function GetLoginName ($IP) {
exec("nbtstat -A $IP",$Lines);
$Lines = KeepIf($Lines, "LineIsUser");
$Lines = ArrMap ($Lines, "BeforeFirstSpace");
$Lines = KeepIf($Lines, "Alphabetical");
return $Lines[0];
}
But we ran into a problem. If I log into my machine and the machine next to me with the same username, problems arise. If I run nbtstat on the machine on which I logged in last, I can't find a username in the list, only the domain name and the computer name. So this obviously isn't good since people are going to access this page and will have to be sure they logged off other machines. I want nbtstat to always return the user's login name, but right now it doesn't seem possible.
Is there any way around this? What can be done?
Eric
ASKER
"What you can do is to either get the environment variable %username% or the username property from the
network object (both in Scripting Host)."
This would be very helpful, can you explain how I go about doing this?
Eric
network object (both in Scripting Host)."
This would be very helpful, can you explain how I go about doing this?
Eric
If you set the netbios node type to B-node does nbtstat query the machine or does it ask the browsemaster?
ASKER
I have no idea what you mean, I'm not the network administrator if that has anything to do with it.
Eric
Eric
ASKER
I have no idea what you mean, I'm not the network administrator if that has anything to do with it.
Eric
Eric
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The page simply takes your ip number and then uses that and nbtstat to find you in a database and pull information on you. I have no idea how to use WMI, so is there any hope?
Eric
Eric
What you can do is to either get the environment variable %username% or the username property from the network object (both in Scripting Host).