|
-
Sep 30th, 2005, 09:19 PM
#1
Thread Starter
Junior Member
Determine computer name where user is logon
OS: Windows 98
Server OS: Linux 9 + Samba 3
VB6
I wrote a small program where a user can send message using mailslots (winpopup style) problem is if a person send a message using computer name, it is ok. But when a user send a message using the username the message is not sent.
for instance, if user "USER1" logon to computer "PC01" and another user send a message using "USER1". The message will not be sent. But if the user will use "PC01" to send message, the message will be received by "USER1" on "PC01".
I was able to determine if computer is online by using IsDestinationReachable() but I can't determine the computer name where a user logon.
I need to determine the computer name where a user is logon because i think mailslot uses \\"computername"\mailslot\messngr.
Please help, I've been searching for this on the net for days now. Thanks in advance.
-
Sep 30th, 2005, 09:21 PM
#2
Frenzied Member
Re: Determine computer name where user is logon
is this what you need?
VB Code:
Private Declare Function GetComName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Command1_Click()
Dim com_name As String
Dim length As Long
com_name = Space$(256)
length = Len(com_name)
GetComName com_name, length
com_name = Left$(com_name, length)
MsgBox "[" & com_name & "]"
End Sub
-
Sep 30th, 2005, 09:58 PM
#3
Thread Starter
Junior Member
Re: Determine computer name where user is logon
thank you for your reply but it's not what im looking for, GetComputerName() is used to get the computer name of the current system
What Im looking for is how to get the computer name of a user where he is logged in.
example is if a user would send message to "USER1" the system must determine first on what computer is "USER1" logged in so I can user the computer name on the mailslot \\"computername"\mailslot\messngr.
what I want to achieve is to :
Determine on what computer a user is logged in on a network environment.
Thanks, I appreciate your help.
-
Oct 2nd, 2005, 08:57 PM
#4
Thread Starter
Junior Member
Re: Determine computer name where user is logon
Any suggestions please ? Is this Impossible on Win98 OS ?
-
Oct 2nd, 2005, 09:09 PM
#5
Re: Determine computer name where user is logon
Does this help:
VB Code:
MsgBox Environ("COMPUTERNAME")
-
Oct 2nd, 2005, 09:10 PM
#6
Re: Determine computer name where user is logon
Actually, its probably the same as GetComp API
-
Oct 2nd, 2005, 09:12 PM
#7
Re: Determine computer name where user is logon
Your after the Server end right?
-
Oct 2nd, 2005, 09:14 PM
#8
Re: Determine computer name where user is logon
I think he needs the computername of the machine that he is sending the message to. Just like Net Send, you specify the computername you are sending TO not the one you are at.
-
Oct 2nd, 2005, 09:18 PM
#9
Re: Determine computer name where user is logon
I reread the original. Try mosding this to get the User matched to CompName!
VB Code:
Private Sub Load_Users()
Dim objDomain As Object
Dim objUser As Object
On Error GoTo Err_Handler
Set objDomain = GetObject("WinNT://" & Environ$("USERDNSDOMAIN"))
Set objUser = GetObject(objDomain.Schema)
objDomain.Filter = Array("User")
For Each objUser In objDomain
cboUsers.AddItem objUser.Name
Next
Set objDomain = Nothing
Set objUser = Nothing
Exit Sub
Err_Handler:
Screen.MousePointer = vbNormal
If Not (objDomain Is Nothing) Then Set objDomain = Nothing
If Not (objUser Is Nothing) Then Set objUser = Nothing
MsgBox "Description: " & Err.Description & vbCrLf & _
"Number: " & Err.Number, vbInformation + vbOKOnly, App.Title & " - Error"
End Sub
-
Oct 2nd, 2005, 11:07 PM
#10
Thread Starter
Junior Member
Re: Determine computer name where user is logon
Thank you for your reply. I tried the code, and get this error
File name or class name not found during Automation operation Number 432
at this line
Code:
Set objDomain = GetObject("WinNT://" & Environ$("USERDNSDOMAIN"))
-
Oct 2nd, 2005, 11:13 PM
#11
Thread Starter
Junior Member
Re: Determine computer name where user is logon
 Originally Posted by Bruce Fox
Actually, its probably the same as GetComp API
Getcomputername API is for the current system. What I need is the computer name of the user where I am sending the message. Some users use the username instead of the computer name when sending messages.
mailslot uses //computername/mailslot/messngr to send message that's why I need to know the "computer name" of the recipient.
Thanks for the help, I appreciate it.
Any more suggestions please.
-
Oct 2nd, 2005, 11:56 PM
#12
Re: Determine computer name where user is logon
Not sure if this applies with mailslots... but if I'm not mistaken, winpop is based on dos command net. With net, you can get the names used by the local machine with net name, the pc name and the active profile name. net user lists all users including non active profiles.
I'ts possible to net send msgs with net using the active user/profile name instead of the computer name since net does the mapping. UNfortunately I dont know the API for net.
-
Oct 3rd, 2005, 12:26 AM
#13
Thread Starter
Junior Member
Re: Determine computer name where user is logon
 Originally Posted by leinad31
Not sure if this applies with mailslots... but if I'm not mistaken, winpop is based on dos command net. With net, you can get the names used by the local machine with net name, the pc name and the active profile name. net user lists all users including non active profiles.
I'ts possible to net send msgs with net using the active user/profile name instead of the computer name since net does the mapping. UNfortunately I dont know the API for net.
Thank you for your help. I think Windows 98 Net command doesn't recognize NET SEND and NET NAME
-
Oct 3rd, 2005, 04:11 AM
#14
Re: Determine computer name where user is logon
 Originally Posted by kenchix1
OS: Windows 98
My appologies kenchix1,
I should have read closer.... the example I provided will (as far as I know) only work
for an NT based OS (Y2K/XP).
Sorry
-
Oct 3rd, 2005, 05:35 AM
#15
Frenzied Member
Re: Determine computer name where user is logon
does theapp needs the name for anything but display? if not then just let the user type in his name and the app will recognize the user and show his name
-
Oct 3rd, 2005, 06:57 PM
#16
Thread Starter
Junior Member
Re: Determine computer name where user is logon
 Originally Posted by Bruce Fox
My appologies kenchix1,
I should have read closer.... the example I provided will (as far as I know) only work
for an NT based OS (Y2K/XP).
Sorry 
No problem. your help is appreciated. 
 Originally Posted by wiz126
does theapp needs the name for anything but display? if not then just let the user type in his name and the app will recognize the user and show his name
The application needs the name for the mailslot which is the \\computername\mailslot\messngr. If a user types in a username instead of computer name, the message will not be sent because the system will use the username on the computername portion of the string, which leads to nothing. That's why I need to locate the recipients computer so I can get his computername.
Thanks for the help.
-
Oct 4th, 2005, 06:42 AM
#17
Re: Determine computer name where user is logon
Broadcast it on the domain... and change the info of the datagram. Include a "header" in the message portion that contains the user name. So during a broadcast, each recipient does an adiitional check against the username in the header to see if it is really addressed to him since the sender couldnt identify the specific computer.
In the case that the computer name is known, the "header" could be left blank or still has a user name... whichever is easier to code.
-
Oct 4th, 2005, 11:37 PM
#18
Thread Starter
Junior Member
Re: Determine computer name where user is logon
 Originally Posted by leinad31
Broadcast it on the domain... and change the info of the datagram. Include a "header" in the message portion that contains the user name. So during a broadcast, each recipient does an adiitional check against the username in the header to see if it is really addressed to him since the sender couldnt identify the specific computer.
In the case that the computer name is known, the "header" could be left blank or still has a user name... whichever is easier to code.
wouldn't that cause too much traffic on the network ? aside from it, I don't know how to broadcast a message.
thank you for the info.
(Im still stuck on this problem)
-
Oct 4th, 2005, 11:45 PM
#19
Frenzied Member
Re: Determine computer name where user is logon
there is one way i have been able to resolve this problem (it is not the best, trust me)
my office has over 70 computers with oses ranging from win 98 to win xp sp2.
what i did was create a server module which would record which user has logged into which computer. this is done by having a small client sending information to the server module on logon. this way, i was able to trace who was logged in where.
-
Oct 5th, 2005, 04:55 PM
#20
Re: Determine computer name where user is logon
He wanted to do it like winpop... and he's concerned with traffic. A server would need to check every once in awhile if its list is correct or up to date.
-
Oct 12th, 2005, 11:25 PM
#21
Thread Starter
Junior Member
Re: Determine computer name where user is logon
I've been searching for weeks now but still can't find a solution on how to solve this problem. the nearest possible solution that I saw was to broadcast a name query via UDP port 137 posted by somebody two years ago. but how ?
i just hope those winpopup programmers that knows how to determine a computer name of a certain user on the network are not from other planets.
-
Oct 13th, 2005, 10:04 AM
#22
Re: Determine computer name where user is logon
Have you tried this name?
\\*\mailslot\name
Retrieves a client handle to all mailslots with the specified name in the system's primary domain.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|