Re: select directory on remote machine using WMI

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Willy Denoyette [MVP] wrote:
"CosminB [BRT]" <cosminb@xxxxxxxxx> wrote in message
news:1158577832.412730.81360@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|I thought this is the way to go... any other ideas?

No, this is one way to go but maybe not the best.
The DirectoryInfo class accepts a UNC path like \\\\MyServer\\MyShare, so
you may use this one to connect/access a remote share or drive. Sure you
need access privileges to the remote resource, but this can be achieved by
1) impersonation or 2) by establishing a network session with the resource.
Option 2 is simple, just issue a 'net use ...' command (from the commandline
or using Process.Start), specifying the network path and the credentials
needed. Option 1 is more involving and wight not work if the client is
running W2K, basically you have to retrieve an access token by calling
LogonUser through PInvoke specifying the credentials for which you want to
obtain a token, use this token to Impersonate. Search MSDN for a sample
(look for LogonUser).

Willy.

I need to be sure it works on W2K also. As for option 2, I need to be
able to select any drive the remote host has... anyway, I've found a
way, with WMI, like this:

SELECT * FROM CMI_LogicalFile WHERE Path="\\somepath\\" AND Drive="X:"

and the drives, I get them with:

SELECT * FROM CMI_LogicalDisk

I don't mind doing a little extra work, but this seems fine, I hope it
will work well.

Thanks for the quick replies,
Cosmin.

.



Relevant Pages

  • Re: Problem establishing SSL connection in code-behind
    ... credentials and create a logon token for them that can be used to start ... Therefore, to authenticate AD users on the web server, the ... I don't understand why you need to log on to a remote machine. ... The Win32 LogonUser API is completely new to me. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Copy files in network with authentication ??
    ... >> The purpose of LogonUser is to obtain an access token specifying the ... >> credentials of a valid local or domain (remote) account. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: A services threads outgoing security:how to manage?
    ... In my situation, I cannot use "LogonUser", because ... the credentials I have to access the remote machine, ...
    (microsoft.public.dotnet.security)
  • Re: A services threads outgoing security:how to manage?
    ... In my situation, I cannot use "LogonUser", because ... the credentials I have to access the remote machine, ...
    (microsoft.public.security)
  • Re: Mapped Drives over VPN
    ... When the client tries to access a share on the remote machine, ... Microsoft CSS Online Newsgroup Support ... | They have generally two mapped drives. ...
    (microsoft.public.windows.server.sbs)