views:

471

answers:

1

Where does NetServerEnum() get its list of machines from?

Does it use the computer browser service or will it use AD as a preference if AD is available?

Links:

+1  A: 

From the Browser service. NetServerEnum pre-dates Active Directory, and has to run on non-AD systems. NetServerEnum will return 6118 (no browsers) if it can't find a browse server. I think AD has the ADSI interface for this kind of task, but I never programmed against AD.

Note that NetServerEnum can be unconscionably slow on a large domain: I found this out the hard way by trying to use NSE for a rudimentary "discovery" algorithm. Soon learned my lesson and swapped to UDP for that task.

Bob Moore
Hi Bob, I'm having the same problem with the NetServerEnum function stalling. When you say you've used UDP instead, how exactly did you use the protocol? I appreciate your help.
Andy
Broadcast a (small) UDP packet using sendto with INADDR_BROADCAST when you start up. In the ping message, put the originator's data such as IP address. Do it (slowly) several times because UDP is unreliable. If the rxr has no current TCP connection to the originator, when it receives a ping it tries to connect back via TCP. NB: won't work across a router: you need to maintain your own IP connection list for that case. Can't post code, it belongs to my employer. Note: under IPv6 there's no equivalent, you need multicast for that.
Bob Moore