Open GoogleCodeExporter opened 9 years ago
Yeah, I'm a bit stumped on this one so far. I think it's a NetBIOS issue, but I
haven't tried to track it down in depth yet. See this thread for suggestions:
http://groups.google.com/group/cassia-users/browse_thread/thread/fedeaf1ea74dbbe
0
Original comment by danports
on 16 Jul 2011 at 2:49
i have the same problem:
asp.net application
cassia.net v2.0.0.60
enumerate servers
netbios over tcp is active
mit full domainname is koelbel.local
i use the netbios name KOELBEL
i recieved the error:
wrong domainname
Original comment by thomas89...@googlemail.com
on 17 Jul 2011 at 6:16
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).
Original comment by danports
on 15 Feb 2012 at 3:59
Original comment by danports
on 26 Feb 2012 at 2:19
The RDS API documentation now recommends NetServerEnum for this purpose:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa370623(v=vs.85).aspx
Original comment by danports
on 19 Oct 2012 at 1:41
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.
Original comment by justinlc...@gmail.com
on 28 Mar 2013 at 3:23
Justin: Sure, send me a patch and I'll take a look at it. Did you use a
different Win32 call in NativeMethods?
Original comment by danports
on 29 Mar 2013 at 1:59
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.
Original comment by asbj...@neslekkim.net
on 3 May 2013 at 12:51
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);
}
}
Original comment by danports
on 6 Sep 2013 at 1:54
Original issue reported on code.google.com by
thomas89...@googlemail.com
on 16 Jul 2011 at 12:18