NTLM + Jcifs SID.getGroupMemberSids()

Hi all,

Is it possible to use JCIFS to return all users from a Domain as well as all groups from that domain?

I have been studying the source code for jcifs 1.3.0 and found a class SID.java. Inside, there are few interesting methods such as getGroupMemberSids.

I have been playing with the code but I did not make much progress. Any comments, suggestions, howtos, pointers, etc are greatly appreciated. Thanks.

import jcifs.UniAddress;
import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbSession;
import jcifs.smb.NtlmContext;
import jcifs.ntlmssp.NtlmFlags;
import jcifs.smb.SID;
import java.net.InetAddress;
public class simpleJavaAuthenticationTest {
	public static void main(String[] args) {
		try {
			InetAddress ip = InetAddress.getByName("");
			UniAddress myDomain = new UniAddress(ip);
			NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("test.mydomain","carlosscheidecker","test");
			SmbSession.logon(myDomain, auth);
			System.out.println("Hostname: "+ myDomain.getHostName());
			jcifs.smb.SID mySid = jcifs.smb.SID.getServerSid(myDomain.getHostName(), auth);
			System.out.println("Sid Domain Name: "+ auth.getName());
			System.out.println("Sid Domain SID: " +mySid.getDomainSid());
			SID[] groupMembers = mySid.getGroupMemberSids(auth.getName(), auth, SID.SID_TYPE_USER);
			System.out.println("Total SIDs = "+groupMembers.length);
			for (int i = 0; i < groupMembers.length; i++ ) {
				System.out.println("Sid["+i+"] GroupMembersSids: " +mySid.getAccountName());
		} catch (Exception e) {
			System.out.println("Exception : "+e.toString());

Open in new window

Who is Participating?
CarlosScheideckerConnect With a Mentor Author Commented:
Used LDAP for the needs I have as per talk with JCIFs developers. Not want I wanted but did the trick.
All Courses

From novice to tech pro — start learning today.