Coder Social home page Coder Social logo

Comments (9)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
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

from cassia.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024

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 [email protected] on 17 Jul 2011 at 6:16

from cassia.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
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

  • Changed title: Update documentation for GetServers to indicate dependency on NetBIOS and to suggest alternatives
  • Changed state: Accepted
  • Added labels: Milestone-2.1, Priority-Low, Type-Enhancement
  • Removed labels: Priority-Medium, Type-Defect

from cassia.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024

Original comment by danports on 26 Feb 2012 at 2:19

  • Added labels: Estimate-1

from cassia.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
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

from cassia.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
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 [email protected] on 28 Mar 2013 at 3:23

from cassia.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
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

from cassia.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
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 [email protected] on 3 May 2013 at 12:51

from cassia.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
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

from cassia.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.