View Full Version : Get network mapped drives of session from service running on XP/2003
Michael Sternberg
07-17-2004, 09:56 PM
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
07-18-2004, 01:41 AM
Hi !
"Michael Sternberg" <mishka@sdf.lonestar.org> wrote in message
news:fd8eb3f4.0407172156.6f599386@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
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. --
Michael Sternberg
07-18-2004, 05:13 AM
"Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote... "Michael Sternberg" <mishka@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
07-18-2004, 07:59 AM
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" <mishka@sdf.lonestar.org> wrote in message
news:fd8eb3f4.0407180513.6d061ebf@posting.google.com... "Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote... "Michael Sternberg" <mishka@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..
Eugene Gershnik
07-18-2004, 12:31 PM
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
07-18-2004, 10:51 PM
"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
07-18-2004, 11:16 PM
"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
07-18-2004, 11:39 PM
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
07-19-2004, 10:42 PM
"Eugene Gershnik" wrote: Michael Sternberg wrote: 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.
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
07-20-2004, 03:52 AM
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
07-20-2004, 06:08 AM
Michael Sternberg wrote: "Eugene Gershnik" wrote: Michael Sternberg wrote: 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. Thanks a lot. Now can you just push me into the right direction 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
07-20-2004, 06:37 AM
"Michael Sternberg" <mishka@sdf.lonestar.org> wrote in message
news:fd8eb3f4.0407200608.32a8e0f9@posting.google.com... Michael Sternberg wrote: "Eugene Gershnik" wrote: Michael Sternberg wrote: > 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. Thanks a lot. Now can you just push me into the right direction 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..
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
MyLounge.com Site Map
Forum:
Cars,
Cell Phone,
Database,
Games,
Home Improvement,
IT,
Music,
School,
Sports,
Web Design,
Web Server,
Weight Loss
The MyLounge.com forum is intended for informational use only and should not
be relied upon and is not a substitute for any advice. The information contained
on MyLounge.com are opinions and suggestions of members and is not a representation
of the opinions of MyLounge.com. MyLounge.com does not warrant or vouch for
the accuracy, completeness or usefulness of any postings or the qualifications
of any person responding. Please consult a expert or seek the services of an
attorney in your area for more accuracy on your specific situation. Please note
that our forums also serve as mirrors to Usenet newsgroups. Many posts you see
on our forums are made by newsgroup users who may not be members of MyLounge.com
Term of Service
vBulletin v3.0.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.