Re: How to get current drive mapping
- From: Dave <Dave@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 20 Mar 2007 04:35:05 -0700
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
- References:
- Re: How to get current drive mapping
- From: Nicholas Paldino [.NET/C# MVP]
- Re: How to get current drive mapping
- From: Nicholas Paldino [.NET/C# MVP]
- Re: How to get current drive mapping
- Prev by Date: Re: Timers and WebServices
- Next by Date: Re: op_Equality (== Operator) for Value-Types
- Previous by thread: Re: How to get current drive mapping
- Next by thread: Re: How to get current drive mapping
- Index(es):
Relevant Pages
|