Re: How to get current drive mapping



Yes, I also thought of that, but, as you say, without the user's logon
password it can't work.
Willy Denoyette suggests I use WMI. Sadly there are also problems with that
(see my last post) because of a bug that requires a hotfix. Nevertheless, if
the bug is fixed then allegedly WMI can get the information I need - which
begs the question, how does WMI get the information? If WMI can get it from
the operating system, then surely an application should also be able to get
it directly from the OS without going through WMI.
--
Dave


"Nicholas Paldino [.NET/C# MVP]" wrote:

Dave,

The only way I can think of possibly doing this would be to impersonate
the user that ran the process and then run WNetGetUniversalName while
impersonating. However, in order to do that, you will have to have access
to each user's username (easy) and password (not so easy) so you can make
the call to LogonUser.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Dave" <Dave@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5DBE7799-5B44-4AC4-B187-47B520A9A0C5@xxxxxxxxxxxxxxxx
Thanks Nicholas, but I think you've slightly misunderstood - I don't have
a
"client process" - I am getting a list of the currently running processes
and
trying to find out where they were run from.
I've looked at WNetGetUniversalName but it has the same problem as
WNetGetConnection which I am using now - it will only resolve drive
mappings
for the current logon session.
The Process.Mainmodule.FullPath gives me the location, but (for some
strange
reason) with a drive letter not a UNC. I can find the user account of the
process, and the sessionID, so surely it must be possible to find the
current
drive mapping for that logon session and thus the UNC path. (Of course,
the
mapping may have changed since the process was started, but there's not
much
I can do about that)
--
Dave


"Nicholas Paldino [.NET/C# MVP]" wrote:

Dave,

Unfortunately, the only option that you have here is to have the
client
process do the resolution of the mapped drive to the UNC path. You can
do
this on the client with the WNetGetUniversalName API function (you will
have
to make the call through the P/Invoke layer).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Dave" <Dave@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5D025924-A27A-4942-900F-FEE0EFBAA80E@xxxxxxxxxxxxxxxx
I am actually trying to get the UNC path of the main module of a process
running from a mapped drive, and I am trying to do this from a service.
The
ProcessModule class only provides the full path with the mapped drive
letter,
but the drive letter refers to the drive mapping for the user that
started
the process, and cannot be resolved to a UNC path from a service
running
under LocalSystem.
Presumably, therefore, I need to get the drive mapping either for the
user
account associated with the process, or possibly even for the process's
session ID (I am not clear whether mappings are per user or per
session).
Can
anyone give me a clue as to how I go about this?
--
Dave






.



Relevant Pages

  • Re: EnumDisplayDevice does not work from within a service under Vi
    ... Before going through the huge doc of WMI and learning how to use it, ... NULL) when it is called from within a service (in session 0), ... that are attached to the display cards. ... On XP/W2K this was perfectly possible but on Vista it ...
    (microsoft.public.win32.programmer.gdi)
  • Re: PdhCollectQueryData wont collect data on WXP after SP2
    ... I suspect somehow that logon and authentication has changed with SP2, ... various newsgroup postings say that XP Home has been giving trouble to WMI ... >> start the app, and then switch user to other users on the system. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Returning a users IP given their username
    ... To retrieve the user name using WMI look at the Win32_ComputerSystem ... You can change the timeout period in Win32_PingStatus like this: ... Having a session on a computer does not mean the user is logged ... UID = UCase ...
    (microsoft.public.scripting.vbscript)
  • Re: Link between Tse User Account and Tse Session?
    ... I am not very clear on what exact user and session information you are ... > I looking for one solutions with WMI to extract datas on "Tse User ... > I have localised several Wmi classes on TSE server: ...
    (microsoft.public.win2000.termserv.clients)
  • Re: Link between Tse User Account and Tse Session?
    ... I am not very clear on what exact user and session information you are ... > I looking for one solutions with WMI to extract datas on "Tse User ... > I have localised several Wmi classes on TSE server: ...
    (microsoft.public.windows.terminal_services)