Page 1 of 1 1
Topic Options
#25674 - 2002-07-23 02:39 PM getting user id from mapped drive
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
I am trying to log an install. The problem is that our pc support techs log on to the machine as administrators to do the install. So, in my log file I get "administrator" as user name instead of the tech's user name.

But they must map a drive to run the install, and therefore they must connect to the drive as themselves. Is there anyway to get the username that mapped the drive?
_________________________
Eric

Top
#25675 - 2002-07-23 02:47 PM Re: getting user id from mapped drive
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Lemme see if I'm translating this properly...

1) Your technicians are logging into your (assuming WinNT 5 or 4) workstations as the local administrator.

2) They connect to a share (and thus must supply their logon credentials to connect) and perform an install.

3) This installation is started from a KiX script and you are trying to capture the username of the user running your script.

How close am I?

Top
#25676 - 2002-07-23 03:20 PM Re: getting user id from mapped drive
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
That's exactly what I'm saying.
_________________________
Eric

Top
#25677 - 2002-07-23 03:39 PM Re: getting user id from mapped drive
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Incorporate the driver mapping into your install script like:
code:
? 'enter username:'
gets $username
? 'enter password:'
gets $password

use y: '\\server\installshare' /user:$username /password:$password

;do the install

use y: /delete /persistent

_________________________
There are two types of vessels, submarines and targets.

Top
#25678 - 2002-07-23 03:56 PM Re: getting user id from mapped drive
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
I would, but the techs don't always log on locally as administrator, sometimes they do log on as themselves. Plus, that would just complicate the script slightly more, and it's not really a pressing issue.

I was just hoping that it might be recorded somewhere in the registry - mapped drive, user that mapped the drive. Something along those lines.
_________________________
Eric

Top
#25679 - 2002-07-23 03:59 PM Re: getting user id from mapped drive
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
It's recorded in the event log and under HKEY_CURRENT_USER\Network. There will be a list of drive letters for manually created shares including the RemotePath and UserName.

That might help, too.
_________________________
There are two types of vessels, submarines and targets.

Top
#25680 - 2002-07-23 04:10 PM Re: getting user id from mapped drive
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
That's exactly what I'm looking for. I'm going to log on to my machine as administrator and give it a shot.

Thanks for the help
_________________________
Eric

Top
#25681 - 2002-07-23 04:10 PM Re: getting user id from mapped drive
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Jens has it pegged exactly. Enum through the HKCU\Network key and look for your share in the RemotePath key, then pull the username from the UserName entry.
Top
#25682 - 2002-07-23 04:40 PM Re: getting user id from mapped drive
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Well, I logged on to my machine as administrator, mapped a drive (as myself) and checked the registry. Unfortunately, the HKCU/Network key did not exist. I'm assuming this is because I'm logging onto the machine locally (win 2k prof).

So I decided to search the registry to see if it might be buried somewhere else, but I couldn't find it anywhere. So I'm starting to believe that there's no easy way to do this.
_________________________
Eric

Top
#25683 - 2002-07-23 04:47 PM Re: getting user id from mapped drive
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I believe they only show up if they are PERSISTENT, I don't think the non-PERSISTENT connections are stored anywhere except maybe WMI.

Ha!

I checked WMI and there they are! All network conenctions are listed under Win32_NetworkConnection. The info contained inside that area tells you wheter it's a persisitent connection and the username used to establish the connection.

so, yeah, go to the COM forum and see whether there's already a function posted that lists network connections.
_________________________
There are two types of vessels, submarines and targets.

Top
#25684 - 2002-07-23 04:51 PM Re: getting user id from mapped drive
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
And just when I was ready to give up. I'll look into it. Thanks.
_________________________
Eric

Top
#25685 - 2002-07-23 07:40 PM Re: getting user id from mapped drive
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
As my luck would go, it works just fine on every mapping I've tried...except the one i need. When I check the status of the mapping with WMI, it comes back with "Error", even though I can open the drive and browse. Not quite sure what "Error" is telling me.

Here's the snippet of code I'm working with:

code:
 
$DiskSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_NetworkConnection")

For each $Disk in $DiskSet
? "Drive: " + $Disk.RemoteName + ", " + "Status: " + $Disk.Status + ", " + "User Name: " + $Disk.UserName
Next


********************OUTPUT*********************

Drive: \\1upmc-sam-001\e$, Status: Degraded, User Name: 1UPMC-ACCT\maciep
Drive: \\new-emanage1\c$, Status: Degraded, User Name: 1UPMC-ACCT\maciep
Drive: \\1upmc-aisrv1\c$, Status: Degraded, User Name: 1UPMC-ACCT\maciep
Drive: \\1upmc-aisrv2\c$, Status: Degraded, User Name: 1UPMC-ACCT\maciep
Drive: \\1upmc-aisrv3\c$, Status: Degraded, User Name: 1UPMC-ACCT\maciep
Drive: \\desktop-02\dfs, Status: Error, User Name:

I have the people who own the share (and know a lot more than I do) thinking about it. Has anyone ever tried this, and if so, come across this problem?
_________________________
Eric

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2375 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.062 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org