Re: Issue 44 in cassia: Update documentation for GetServers to indicate dependency on NetBIOS and to suggest alternatives

23 views
Skip to first unread message

cas...@googlecode.com

unread,
Feb 14, 2012, 11:01:49 PM2/14/12
to cassi...@googlegroups.com
Updates:
Summary: Update documentation for GetServers to indicate dependency on
NetBIOS and to suggest alternatives
Status: Accepted
Labels: -Type-Defect -Priority-Medium Type-Enhancement Priority-Low
Milestone-2.1

Comment #3 on issue 44 by danports: Update documentation for GetServers to
indicate dependency on NetBIOS and to suggest alternatives
http://code.google.com/p/cassia/issues/detail?id=44

See the first comment here:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa383832(v=vs.85).aspx

Apparently the Computer Browser service (for NetBIOS) needs to be running
on a DC for the WTSEnumerateServers to work, and that service is no longer
running by default on 2008+. I think the best we can do here is document
this and suggest that people use another method to enumerate RD servers
(e.g. AD/LDAP queries).

cas...@googlecode.com

unread,
Feb 25, 2012, 9:30:14 PM2/25/12
to cassi...@googlegroups.com
Updates:
Labels: Estimate-1

Comment #4 on issue 44 by danports: Update documentation for GetServers to

indicate dependency on NetBIOS and to suggest alternatives
http://code.google.com/p/cassia/issues/detail?id=44

(No comment was entered for this change.)

cas...@googlecode.com

unread,
Oct 18, 2012, 9:42:08 PM10/18/12
to cassi...@googlegroups.com

Comment #5 on issue 44 by danports: Update documentation for GetServers to
indicate dependency on NetBIOS and to suggest alternatives
http://code.google.com/p/cassia/issues/detail?id=44

The RDS API documentation now recommends NetServerEnum for this purpose:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa370623(v=vs.85).aspx

cas...@googlecode.com

unread,
Mar 28, 2013, 11:23:30 AM3/28/13
to cassi...@googlegroups.com

Comment #6 on issue 44 by justinlc...@gmail.com: Update documentation for
GetServers to indicate dependency on NetBIOS and to suggest alternatives
http://code.google.com/p/cassia/issues/detail?id=44

Awesome library, but I also ran into the same issue. I changed
NativeMethods to work correctly on 2008+ if you're interested in getting
the change and updating the project.

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

cas...@googlecode.com

unread,
Mar 28, 2013, 9:59:55 PM3/28/13
to cassi...@googlegroups.com

Comment #7 on issue 44 by danports: Update documentation for GetServers to
indicate dependency on NetBIOS and to suggest alternatives
http://code.google.com/p/cassia/issues/detail?id=44

Justin: Sure, send me a patch and I'll take a look at it. Did you use a
different Win32 call in NativeMethods?

cas...@googlecode.com

unread,
May 3, 2013, 8:51:30 AM5/3/13
to cassi...@googlegroups.com

Comment #8 on issue 44 by asbj...@neslekkim.net: Update documentation for
GetServers to indicate dependency on NetBIOS and to suggest alternatives
http://code.google.com/p/cassia/issues/detail?id=44

Crashed on the same here now, found that they recomend netserverenum as
noted in the bottom here:
http://msdn.microsoft.com/en-us/library/aa383832(v=vs.85).aspx
But very nice tool when used direct on servernames.

cas...@googlecode.com

unread,
Sep 5, 2013, 9:54:20 PM9/5/13
to cassi...@googlegroups.com

Comment #9 on issue 44 by danports: Update documentation for GetServers to
indicate dependency on NetBIOS and to suggest alternatives
http://code.google.com/p/cassia/issues/detail?id=44

Justin's suggestions -- documenting them here for now until I get a chance
to review the code and make some changes:

in Impl/NativeMethods.cs, line 46:
/* no longer works for Server 2008 and above
[DllImport("Wtsapi32.dll", CharSet = CharSet.Auto, SetLastError =
true)]
public static extern int
WTSEnumerateServers([MarshalAs(UnmanagedType.LPTStr)] string pDomainName,
int reserved,
int version, out
IntPtr ppServerInfo, out int pCount);
*/
//[DllImport("Wtsapi32.dll", CharSet = CharSet.Auto, SetLastError =
true)]
[DllImport("Netapi32.dll", EntryPoint = "NetServerEnum")]
public static extern Int32
NetServerEnum([MarshalAs(UnmanagedType.LPWStr)] String serverName, Int32
level, out IntPtr bufferPtr,
UInt32 prefMaxLen, ref
Int32 entriesRead, ref Int32 totalEntries,
UInt32 serverType,
[MarshalAs(UnmanagedType.LPWStr)] String domain,
IntPtr handle);


[DllImport("Netapi32.dll", EntryPoint = "NetApiBufferFree")]
public static extern UInt32 NetApiBufferFree(IntPtr buffer);



in Impl/NativeMethodsHelper.cs, line 142:
public static IList<WTS_SERVER_INFO> EnumerateServers(string
domainName)
{
IntPtr ppServerInfo;
int count = 0;

int totalEntries = 0;
UInt32 MAX_PREFERRED_LENGTH = 0xFFFFFFFF;
//all servers
UInt32 ServerType = 0xFFFFFFFF;
//only valid up to 2008.
//if (NativeMethods.WTSEnumerateServers(domainName, 0, 1, out
ppServerInfo, out count) == 0)
int result = NativeMethods.NetServerEnum(null, 100, out
ppServerInfo, MAX_PREFERRED_LENGTH, ref count, ref totalEntries,
ServerType, domainName, IntPtr.Zero);
if (result == 234)
{
throw new Win32Exception();
}
try
{
return PtrToStructureList<WTS_SERVER_INFO>(ppServerInfo,
count);
}
finally
{
NativeMethods.WTSFreeMemory(ppServerInfo);
Reply all
Reply to author
Forward
0 new messages