Re: match machine name to user name
From: Roland Hall (nobody_at_nowhere)
Date: 01/26/05
- Next message: Torgeir Bakken \(MVP\): "Re: SENDKEYS + Batch Process"
- Previous message: CHIN_at_KD: "SENDKEYS + Batch Process"
- In reply to: PaulD: "Re: match machine name to user name"
- Next in thread: PaulD: "Re: match machine name to user name"
- Reply: PaulD: "Re: match machine name to user name"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 26 Jan 2005 11:40:30 -0600
"PaulD" wrote in message news:usK7Rd8AFHA.2016@TK2MSFTNGP15.phx.gbl...
:
: "Roland Hall" <nobody@nowhere> wrote in message
: news:e4WZSHxAFHA.3708@TK2MSFTNGP14.phx.gbl...
: > "PaulD" wrote in message news:OA0DQBwAFHA.1296@TK2MSFTNGP10.phx.gbl...
: > : the machine logged in is from some code I found - I don't remember
where
: > it
: > : came from
: > :
: > : Set cn = CreateObject("ADODB.Connection")
: > : cn.Provider = "Microsoft.Jet.OLEDB.4.0"
: > : cn.Open "Data Source=\\Server\database.mdb"
: > :
: > : Set rs = CreateObject("ADODB.Recordset")
: > : Set rs = cn.OpenSchema(-1,
,"{947bb102-5d43-11d1-bdbf-00c04fb92675}")
: > :
: > : So it basically uses an OpenSchema to determine the machines logged
into
: > it.
: > : The returned recordset has the machine name logged in as one of the
: > fields.
: > : The database I'm connecting to does not store the machine name or user
: > names
: > : in it. I know our server (running SBS 2003) has the machine name
linked
: > to
: > : a user name, but I was trying to keep this simple and I'm not sure how
: to
: > : query the server from a client for a username based on a machine name.
: > : Thanks for your help
: > : Paul D
: >
: > Paul...
: >
: > It reads better if you post inline or at the bottom.
: >
: > Ok, I have one more question. Does the person running this have domain
: > admin rights? If you have the workstation name, you can always query
the
: > workstation for the logged on user.
: >
: > Someone may correct my error but I think username and password are
: optional
: > and only needed if current user running this does not have logon
: > credentials.
: >
: > I save this file as getuser.vbs and call for it with: getuser
: > <computername>. You could always extend it and pass username and/or
: > password with oArgs(1), oArgs(2) and then set:
: > sUser = oArgs(1)
: > sPass = oArgs(2)
: > These would pass in plain text so not recommended.
: >
: > Option Explicit
: > dim strComputer, oConn, colComputer, oComputer, oLocator, sUser, sPass
: > dim oArgs
: > set oArgs = wscript.arguments
: > sUser = "yourdomain\administrator"
: > sPass = "adminpassword"
: > if oArgs.length > 0 then
: > strComputer = oArgs(0)
: > Set oLocator = CreateObject("WbemScripting.SWbemLocator")
: > Set oConn = oLocator.ConnectServer(strComputer, "root\cimv2", sUser,
: > sPass)
: > oConn.Security_.ImpersonationLevel = 3
: > Set colComputer = oConn.ExecQuery ("Select * from
Win32_ComputerSystem")
: > For Each oComputer in colComputer
: > Wscript.Echo oComputer.UserName
: > Next
: > else
: > wscript.echo "Error" & vbCrLf & _
: > "Syntax: getuser computername"
: > end if
: > set oArgs = nothing
: > set oLocator = nothing
: > set oConn = nothing
: > set colComputer = nothing
: >
: > HTH...
:
: I will be running the script from my machine. I don't think I have domain
: rights but I do have access to the server by remote and can change
security
: levels as needed. Is it better to use the script to poll the server or to
: poll each machine?
The script polls the client to get the logged on user. Perhaps there is an
area where you can get the logged on user to the server, from the server,
but I don't know what that is off the top of my head. To get it from the
client, it just requires credentials, usually a member of the domain admins
group.
: I am going to try your script and see how it works.
:
: While I GREATLY appreciate your help and do not want to argue with you but
: your comment
: >>It reads better if you post inline or at the bottom<<
: Is merely your opinion.
Almost, it's more of a newsnet majority thang AFAIK. I don't follow polls
but it could be +/- 3 points off. My opinion is if it is a quick reply and
no discussion, at the top is best. If it is a discussion that requires
multiple response, then inline with trimmed quotes. At the bottom is
better, IMHO, rather than top posting if there is a discussion. We can
agree to disagree. Arguments are, IMHO, debates. Heated arguments are
different because it may involve physical contact! (O:=
I saw a tag, yesterday I think, from a guy named Randy, I think it was. I'm
almost positive............I think.
This will paraphrase as I don't remember the whole tag.
Answer: ???
Question: ???
Answer: Top Posting
Question: What is the most annoying thing on newsnet?
I thought it was a clever tag.
: I personally feel it reads better to post the
: newest comments at top.
To each his own. For a person involved in the conversation, I think as long
as its consistent, it probably doesn't matter. For others who come to the
discussion late, I think it's better if it reads like a book. I'm not aware
of any books, written in English, that read from bottom to top, but I could
be wrong. (O:=
: This way I don't have to scroll all over the place
: trying to find a response (I do us inline on occasion when it makes sense
: for answering multiple questions). Or when using the readers, clicking on
: each message shows the most current information typed first, again without
: having to scroll. In our office, all notes are entered newest on top for
: ease of viewing, so I guess I am used to reading 'bottom up'.
:
: As the saying goes 'to each his own' and thanks again, while posting
: comments for you I will post at the bottom :)
What a nice guy! (O:=
-- Roland Hall /* This information is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. */ Technet Script Center - http://www.microsoft.com/technet/scriptcenter/ WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp MSDN Library - http://msdn.microsoft.com/library/default.asp
- Next message: Torgeir Bakken \(MVP\): "Re: SENDKEYS + Batch Process"
- Previous message: CHIN_at_KD: "SENDKEYS + Batch Process"
- In reply to: PaulD: "Re: match machine name to user name"
- Next in thread: PaulD: "Re: match machine name to user name"
- Reply: PaulD: "Re: match machine name to user name"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|