How to view the directory information of the neighbor computer

  • Thread starter Thread starter zeeway
  • Start date Start date
Z

zeeway

hi,everyone
I have a question about viewing the directory information of the remote
computer in the local network. I used the C# class: OpenFileDialog which can
not browse other computer's directory information. How can I view the whole
directory information of other computer given that I have one of its
administrator account. Could anyone help me? Thank you in advance.

Best Regard

Zeeway
 
Hello, zeeway!

You can use WMI ( Win32_Directory ).
or
if you have admin account you can view contents of computers disk,
you access for instance disk C, you will use fillowing UNC path \\computername\C$

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
Thank you. I have tried the code:

ConnectionOptions Conn = new ConnectionOptions();
Conn.Username ="test";
Conn.Password ="123";
ManagementPath p = new ManagementPath("\\\\192.168.1.9\\root\\cimv2");
ManagementScope ms = new ManagementScope(p,Conn);
ObjectQuery oq = new ObjectQuery("SELECT * FROM Win32_LogicalDisk");
ManagementObjectSearcher link = new ManagementObjectSearcher(ms,oq);
ManagementObjectCollection queryCollection = link.Get();
foreach (ManagementObject dsk in Collection)
{
Console.Write(dsk["Caption"]);
}

It can help me accquire basic disk information on the remote computer, but
the directory and file information on a certain disk still can not be
abtained.
Can you give me a hand any more?
Best Regard

Zeeway
 
Hello, zeeway!

z> It can help me accquire basic disk information on the remote computer,
z> but the directory and file information on a certain disk still can not
z> be abtained.

Why can't you use smth like this?
string [] fileEntries = Directory.GetFiles(\\servername\$C); //for disk C access
and the same for other disk in the system ( info about them can be obtained via WMI )

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
Hello, Vadym!

z>> It can help me accquire basic disk information on the remote computer,
z>> but the directory and file information on a certain disk still can not
z>> be abtained.

VS> Why can't you use smth like this?
VS> string [] fileEntries = Directory.GetFiles(\\servername\$C); //for disk
VS> C access and the same for other disk in the system ( info about them
VS> can be obtained via WMI )

oops I meant
string [] fileEntries = Directory.GetFiles(\\servername\C$);


--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
Hi,
I'm sorry for answering you so late.
Following your advice,I can read the files information now. But if the
remote computer wants me to provide one account and its password to verify
whether I can visit it,Could you tell me where I can specifiy the account
and its password. Thanks a lot.

Best Regard

Zeeway
2006-06-05
 
Hi Vadym,
I tried LogonUser API with the demo as you told me,but I found that
LogonUser returns true when I specify a local user name and its password no
matter what domain I specified. So what does the domain parameter mean? When
the domain is a remote computer and the userName and its password belongs to
the remote computer, LoginUser return false.
Could you give me more detail about the usage of LogonUser?
Best Regard

Zeeway
2006-06-07
 
Hello, zeeway!

z> Hi Vadym,
z> I tried LogonUser API with the demo as you told me,but I found that
z> LogonUser returns true when I specify a local user name and its password
z> no matter what domain I specified. So what does the domain parameter
z> mean? When the domain is a remote computer and the userName and its
z> password belongs to the remote computer, LoginUser return false.
z> Could you give me more detail about the usage of LogonUser?
z> Best Regard

LogonUser returns security access token. This token is further used with impersonation.
Domain parameter is used if you want to obtain access token of the domain account.

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
That's the whole point, LogonUser is an API used to authenticate a user,
when authentication succeeds an "access token" is returned, this token can
further be used to impersonate, but this isn't the same as "log on" to a
remote computer.

Willy.

| Hi Vadym,
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthn/se
| curity/logonuser.asp
| It's said that :You cannot use LogonUser to log on to a remote computer.
|
| Best Regard
|
| Zeeway
| 06.06.08
|
|
 
Back
Top