473,799 Members | 3,817 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Enumerating Windows Network Resources

I am trying to implement a crawler in C# that scans all
the shared folders in remote computers in a windows
network. Are there classes in .NET to do this directly?
Please help.

Thank You.
Rohan
Nov 15 '05 #1
7 3168
Rohan,

Your best bet would be to use the classes in the System.Manageme nt namespace, as they wrap access to the Windows Management Interface (WMI). This will give you access to most of the information about machines in a consistent, abstract manner. Once you know how to use these classes, you will want to search for instances of the Win32_Share WMI class on the machine to see what is shared.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- nick(d0t)paldin o=At-exisconsulting' dot|com

On Mon, 6 Oct 2003 03:30:41 -0700, Rohan Ranade <ro**********@y ahoo.com> wrote:
I am trying to implement a crawler in C# that scans all
the shared folders in remote computers in a windows
network. Are there classes in .NET to do this directly?
Please help.

Thank You.
Rohan

Nov 15 '05 #2
Nicholas, Rohan

Just a small remark, like Nicholas has said WMI is the way to go, however there's a little issue which is security related.
Using windows, whenever you want to access remote resources, you need to have access rights to the computers exposing these
resources.
The same applies to WMI, when you need to query remote WMI services, you'll need to have appropriate access rights to do so. Per
default the WMI service is only accessible from the local system, so you will need to give explicit remote access rights for a
specific user on every system you want to query through WMI.

Willy.

"Nicholas Paldino [.NET/C# MVP]" <ni************ **@exisconsulti ng.com> wrote in message
news:op******** ******@msnews.m icrosoft.com...
Rohan,

Your best bet would be to use the classes in the System.Manageme nt namespace, as they wrap access to the Windows Management Interface (WMI). This will give you access to most of the information about machines in a consistent, abstract manner. Once you
know how to use these classes, you will want to search for instances of the Win32_Share WMI class on the machine to see what is
shared.
Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- nick(d0t)paldin o=At-exisconsulting' dot|com

On Mon, 6 Oct 2003 03:30:41 -0700, Rohan Ranade <ro**********@y ahoo.com> wrote:
I am trying to implement a crawler in C# that scans all
the shared folders in remote computers in a windows
network. Are there classes in .NET to do this directly?
Please help.

Thank You.
Rohan


Nov 15 '05 #3
Willy is right, unfortunately. I have exactly this problem.
I need to make a list of shared folders for each particular computer in
a domain. But I have to be logged on as a ordinary user. Then every time
I get "Acces denied".
What other means could I use to make the described list?
(using C# classes, not API) Is it possible through Active directory?

Thx in advance

stej
Nicholas, Rohan

Just a small remark, like Nicholas has said WMI is the way to go,
however there's a little issue which is security related.
Using windows, whenever you want to access remote resources, you need to
have access rights to the computers exposing these
resources.
The same applies to WMI, when you need to query remote WMI services,
you'll need to have appropriate access rights to do so. Per
default the WMI service is only accessible from the local system, so you
will need to give explicit remote access rights for a
specific user on every system you want to query through WMI.

Willy.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #4
When running in a Domain, be it an NT or AD you could assign such privilege
to the "Domain users" group.

Willy.

"pepa stefan" <ce*********@se znam.cz> wrote in message
news:uM******** ******@TK2MSFTN GP11.phx.gbl...
Willy is right, unfortunately. I have exactly this problem.
I need to make a list of shared folders for each particular computer in
a domain. But I have to be logged on as a ordinary user. Then every time
I get "Acces denied".
What other means could I use to make the described list?
(using C# classes, not API) Is it possible through Active directory?

Thx in advance

stej
Nicholas, Rohan

Just a small remark, like Nicholas has said WMI is the way to go,
however there's a little issue which is security related.
Using windows, whenever you want to access remote resources, you need to
have access rights to the computers exposing these
resources.
The same applies to WMI, when you need to query remote WMI services,
you'll need to have appropriate access rights to do so. Per
default the WMI service is only accessible from the local system, so you
will need to give explicit remote access rights for a
specific user on every system you want to query through WMI.

Willy.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #5
Willy, what privilege do you mean?

I'll describe my steps and reasons why I almost gave in.

The first thing I have seen is to set
HKEY_LOCAL_MACH INE\SYSTEM\Curr entControlSet\C ontrol\Lsa to 0
(the same: in Administrative tools folder go to Local security policy
console
browse to: security settings->local policies->security options ->
doubleclick on Network Access: Sharing and Security Model for local
account
and change it to Classis (from Guest only)

That causes that my connection will not be authenticated as Guest user,
but it will use my account (I hope).

But that didn't work.

Next step: Start --> Run --> wmimgmt.msc
right click WMI control and click Properties.
Click Security tab.
In this window I can set for each namespace a security setting. By
default there are listed two accounts (after click on Security button):
1) Admin - he has full rights for everything
2) Everyone - only limited rights and --
"Everyone" doesn't have enabled Remote Access (Remote Enable)

And because I (in this case) belong to Everyone group, I cann't connect.

I'm not allowed to set this option to enabled on each particular
computer I need to connect to (and it would be crazy).

That's all I know about the problem so far, so I don't understand what
privileges ("to the Domain users") you are talking about.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #6
Next step: Start --> Run --> wmimgmt.msc *** This is exactly what I'm talking about, right click WMI control and click Properties.
Click Security tab.
In this window I can set for each namespace a security setting. By
default there are listed two accounts (after click on Security button):
1) Admin - he has full rights for everything
2) Everyone - only limited rights and --
"Everyone" doesn't have enabled Remote Access (Remote Enable)
And because I (in this case) belong to Everyone group, I cann't connect.

*** That's a good thing. You don't want everyone to take control over your
PC isn't it?
I'm not allowed to set this option to enabled on each particular
computer I need to connect to (and it would be crazy).


*** You don't have to give everyone remote access, you need to add "domain
users" or "domain accounts" or whatever group /account to the list with
appropriate privileges to the wanted namespace. Say for instance "remote
access" and "partial write" to "domain users", "execute methods", "remote
access" and "full write" to "domain accounts".
If you are not allowed to do this you can't use WMI to control other
machines on the network, point.

Willy.

Nov 16 '05 #7
Thx very much, that's what I have been looking for, but haven't been
able to found..

stej

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
4135
by: Olivier Parisy | last post by:
Hi all, I'd like to get, in a portable way, a list of all network adapters on a local machine running some python code. socket.gethostname() does not seem enough, as it only returns one name ; I'd like to get all available IPs.
5
8824
by: JohnFol | last post by:
I am using the Win23 API WNetCancelConnection2 and can sucessfully make a connection to a share within my class. The class is called from a Windows Form based test harness. When I instantiate exactly the samce class from a Windows Wervice, I get "A specified logon session does not exist. It may already have been terminated" .. The error number is 1312. I know the code to be good, so I suspect something around security / windows...
4
8362
by: Brian P. Bailey | last post by:
Hello, I'm trying to enumerate the fixed-pitch font families installed on a system. I am _not_ trying to create a generic monospaced font. I've tried looking at: FontFamily InstalledFontCollection Font The closest I could get was to use Font.ToLogFont(...). I should be able to get a GDI LOGFONT structure and then look at the lfPitchAndFamily member.
7
8666
by: Mullin Yu | last post by:
if i put the same code at the windows application or console, i can logon to the computer. but, if i put the same code at the windows service and start it, i still can't logon to the machine. the return value is TRUE. i tested it by going to windows explorer and then click that computer. my coding at windows service:
3
13361
by: Bonj | last post by:
I need to write a windows service, and the only way it can access a shared drive on a file server on the network is if the installer is put in "User" mode - "LocalService", "LocalSystem" and "NetworkService" don't work. i.e. it can't access the shared drive. But in "User" it can. But I don't want it in user mode, if possible. I would rather it be a service. Is there any way to do it?
8
2749
by: Pete Wittig | last post by:
Hello, I am wondering if it is possible to create a networked application with C# that is seen as a windows user. For example, if Bob logged onto windows and then started the application, any access to the network made through the application would be seen as 'C# application user' and not 'Bob'. What I want to accomplish is to create an encrypted folder on a server where files within the folder can be accessed through the application,...
2
2632
by: Joseph Geretz | last post by:
I'm having a credentialing problem in my web application. Actually, I don't think this is an IIS security issue, since I'm able to access the page I'm requesting. However, the executing page itself is not able to access a specific network resource and I just can't figure out why. First of all, let me say this worked fine with IIS running on Win2000 Server. This has not worked since I upgraded to Windows Server 2003. My Platform: Windows...
3
2422
by: serge calderara | last post by:
Dear all, I clearly underdand the advantage of both type of authentification but is it allowed or possible to set the Authentication mode to Windows and then handle a login form for defined users in Credential section like as follow : <authentication mode="Windows" > <forms loginUrl="Login.aspx"> <credentials passwordFormat="Clear"> <user name="Jessee" password="JuneBug"/>
4
2608
by: Shayne H | last post by:
What is the best way to enumerate a grouping of strings? The way I have been doing it is: Public Enum PlatformID Unknown Win16 Win32 Win32NT WinCE End Enum
0
9543
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10237
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10029
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6808
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5588
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.