[jcifs] Reusing NetServerEnum outside of SmbFile?

Eric Glass eric.glass at gmail.com
Tue Jul 20 23:29:30 GMT 2004

> Ideally I'd like to be able to call SmbFile.sendTransaction(req, resp)
> and be able to inspect the response results[] array in my application.
> Any thoughts?

What information are you looking to get?  If you are just looking for
server/workgroup names, you can probably use jcifs.smb.SmbFile; doing:

    SmbFile[] files = new SmbFile("smb://").listFiles();

should give you a list of workgroups/domains; you can do a listFiles()
on each of those to get the servers in the workgroup.

If you are looking for more detailed information (similar to what the
MSDN NetServerEnum call would provide), the jcifs-ext package has an
implementation of much of the network management stuff:


Be forewarned that a lot of this may be buggy; I've had other
priorities and haven't gotten back to touching it up properly.  It may
work for your needs, though, and is similar in usage to the MSDN
equivalents.  You would do something like this:

    String target = "MYSERVER"; // server or domain to contact
    ServerManagement management = new ServerManagement(target);
    int infoLevel = 1; // information level 1
    int serverType = ServerConstants.SV_TYPE_SQLSERVER;
    ServerInfo[] info = management.netServerEnum(infoLevel,
            serverType, "MYDOMAIN");
    for (int i = 0; i < info.length; i++) {
        ServerInfo1 info1 = (ServerInfo1) info[i];
        System.out.println(info1.name + ": " + info1.comment);

This should contact "MYSERVER" and ask it for all SQL servers in
"MYDOMAIN", printing the server name and comment.


More information about the jcifs mailing list