CarlosScheidecker
asked on
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.
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("192.168.230.71");
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());
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.