Get network mapped drives of session from service running on XP/2003

11 views
Skip to first unread message

Michael Sternberg

unread,
Jul 18, 2004, 1:56:28 AM7/18/04
to
Hello

Sorry for crossposting, I need solution urgently. In my application
(service) I have to build a list of all free drive letters, exactly as
logged in user sees them. I do know that network mapped drives are
local to login session. I do know login/password of logged in user. I
can not just write another application (not service) that will supply
this information to my main service via some kind of IPC.

As I understand I need to find a session of my user
(LsaEnumerateLogonSessions and LsaGetLogonSessionData), get LogonId
and .. ??

Thanks.
Michael.

--

Arkady Frenkel

unread,
Jul 18, 2004, 5:41:07 AM7/18/04
to
Hi !

"Michael Sternberg" <mis...@sdf.lonestar.org> wrote in message
news:fd8eb3f4.04071...@posting.google.com...


> Hello
>
> Sorry for crossposting, I need solution urgently. In my application
> (service) I have to build a list of all free drive letters, exactly as
> logged in user sees them. I do know that network mapped drives are
> local to login session.

Not exactly , that like this in XP/WinServer 2003 , but not before , look at
http://support.microsoft.com/?kbid=180362 and restrictions of services to
access drives.
Arkady

Michael Sternberg

unread,
Jul 18, 2004, 9:13:23 AM7/18/04
to
"Arkady Frenkel" <ark...@hotmailxdotx.com> wrote...
>
> "Michael Sternberg" <mis...@sdf.lonestar.org> wrote...

> >
> > In my application
> > (service) I have to build a list of all free drive letters, exactly as
> > logged in user sees them. I do know that network mapped drives are
> > local to login session.
>
> Not exactly , that like this in XP/WinServer 2003 , but not before , look
> at http://support.microsoft.com/?kbid=180362 and restrictions of services
> to access drives.

Well, I'm working in XP/2003 (as the subject says). And according to this
KB article "On Windows XP and on Microsoft Windows Server 2003, each logon
session receives its own set of drive letters..". I'm aware of restriction
that "service cannot access the drive letters that are established in a
different logon session".

Still, I'm looking for way to do it. I have all needed privelegies, I have
login and password of user and I do want to know his/her driver mappings..

Arkady Frenkel

unread,
Jul 18, 2004, 11:59:46 AM7/18/04
to
You cann't use Wnet... in service to query drivers in service , but in user
mode only , that what you don't want.
Maybe ask additionally on
microsoft.public.win32.programmer.kernel how you do can do it in service.

Arkady

"Michael Sternberg" <mis...@sdf.lonestar.org> wrote in message
news:fd8eb3f4.04071...@posting.google.com...

Eugene Gershnik

unread,
Jul 18, 2004, 4:31:18 PM7/18/04
to
Michael Sternberg wrote:
> Hello
>
> Sorry for crossposting, I need solution urgently. In my application
> (service) I have to build a list of all free drive letters, exactly as
> logged in user sees them. I do know that network mapped drives are
> local to login session. I do know login/password of logged in user.

Load user's registry hive and look under the Network key

--
Eugene


Michael Sternberg

unread,
Jul 19, 2004, 2:51:26 AM7/19/04
to
"Eugene Gershnik" wrote:

> Michael Sternberg wrote:
> >
> > Sorry for crossposting, I need solution urgently. In my application
> > (service) I have to build a list of all free drive letters, exactly as
> > logged in user sees them. I do know that network mapped drives are
> > local to login session. I do know login/password of logged in user.
>
> Load user's registry hive and look under the Network key

Not good. You're talking about Win2K. There is no Network key in HKCU in XP.
I've checked with Registry Monitor for all settings in registry that written
when I perform drive mappings. For example I mapped \\server\install to be my
W: on WinXP:

All settings were written to
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2
There is no W: there and also not in whole registry apart from
HKLM\SYSTEM\MountedDevices

I do not think that data about current user network drive mappings is
stored in registry in WinXP and higher, there is should be some API to
retrive it.

Michael Sternberg

unread,
Jul 19, 2004, 3:16:32 AM7/19/04
to
"Eugene Gershnik" wrote:
> Michael Sternberg wrote:
> >
> > Sorry for crossposting, I need solution urgently. In my application
> > (service) I have to build a list of all free drive letters, exactly as
> > logged in user sees them. I do know that network mapped drives are
> > local to login session. I do know login/password of logged in user.
>
> Load user's registry hive and look under the Network key

Oops, sorry for previous message. If I check "Reconnect on logon" when
perform mapping - setting appears in Network in HKCU even on Windows XP.

Now - the problem is when I do not check it. Mapping does not appears even
in Windows 2000 and I do have to know all free volume letters for this user.
On Windows 2000 hovewer calling GetLogicalDrives() from service returns that
letter of mapped volume is busy, just like it should be.

Summary: when running as service on WinXP I want to know free volume
letters of given user even if he mapped network share and did not checked
"Reconnect on logon" checkbox.

Thanks.

Eugene Gershnik

unread,
Jul 19, 2004, 3:39:37 AM7/19/04
to
Michael Sternberg wrote:
> "Eugene Gershnik" wrote:
>> Michael Sternberg wrote:
>>>
>>> Sorry for crossposting, I need solution urgently. In my
>>> application (service) I have to build a list of all free drive
>>> letters, exactly as logged in user sees them. I do know that
>>> network mapped drives are local to login session. I do know
>>> login/password of logged in user.
>>
>> Load user's registry hive and look under the Network key
>

> Summary: when running as service on WinXP I want to know free volume


> letters of given user even if he mapped network share and did not
> checked "Reconnect on logon" checkbox.

Grab WinObj from Sysinternals and take a look under Sessions\<session
id>\DosDevices\
Also check this

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&c2coff=1&safe=off&threadm=f3gsdv8c7dcfpvsfc5lu0pla5m46uk1k51%404ax.com&rnum=1&prev=/groups%3Fq%3D%255Cdevice%255ClanmanRedirector%26hl%3Den%26lr%3D%26ie%3DUTF-8%26c2coff%3D1%26safe%3Doff%26selm%3Df3gsdv8c7dcfpvsfc5lu0pla5m46uk1k51%25404ax.com%26rnum%3D1

You will need to use native API to work with this stuff. Shouldn't be too
hard but ask here or on
microsoft.public.win32.programmer.kernel if you are in trouble.

--
Eugene


Michael Sternberg

unread,
Jul 20, 2004, 2:42:38 AM7/20/04
to

Thanks a lot. Now can you just push me into the right direction and
tell
me what API to look for in MSDN ? Unfortunately there is no sources of
WinObj.exe :(

Eugene Gershnik

unread,
Jul 20, 2004, 7:52:17 AM7/20/04
to
Michael Sternberg wrote:
> Thanks a lot. Now can you just push me into the right direction and
> tell
> me what API to look for in MSDN ?

Native API is an interesting beast. Small parts of it are documented in the
DDK section of MSDN in a very lousy way. Mostly it is left undocumented by
MS (the way things go they will soon stop documenting Win32 too) but there
are numerous sources on the Web and in print that fill this gap. Check
http://undocumented.ntinternals.net/ntundoc.chm and let your employer buy
"Windows NT/2000 Native API Reference" which is worth every buck.

Regarding the API you need start researchning ZwQueryDirectoryObject or
NtQueryDirectoryObject.

--
Eugene

Michael Sternberg

unread,
Jul 20, 2004, 10:08:05 AM7/20/04
to
> tell and me what API to look for in MSDN ? Unfortunately there is

> no sources of WinObj.exe :(

Thanks everybody. Few calls to NtOpenDirectoryObject/NtQueryDirectoryObject
solved the whole problem. I wonder why this API is hidden and undocumented..

Arkady Frenkel

unread,
Jul 20, 2004, 10:37:12 AM7/20/04
to

"Michael Sternberg" <mis...@sdf.lonestar.org> wrote in message
news:fd8eb3f4.04072...@posting.google.com...

That's because it's native API and all ( almost ) set of them not documented
in MSDN , but do documented in Garry Nebbett's book ( Eugene mentioned ) on
page 74... :).
Arkady


Reply all
Reply to author
Forward
0 new messages