[jcifs] Getting SIDs from Domain SIDs

Carlos Scheidecker scheideckerantunes at gmail.com
Tue Nov 11 18:34:38 GMT 2008


After authenticating an user via NTLM, how can I obtain the SID from the User,
not the SID from the Domain?

Note the code snippet. I can obtain the Domain SID from the
NtlmPasswordAuthentication object but I cannot get the current user domain SID
which is what I would like to get to fetch all the group SIDs related to it.

Thanks in advance.

try {
    UniAddress myDomain = getPrimaryDomain(ip);
    NTLMAuth = new NtlmPasswordAuthentication(domainName,userName,password);
    SmbSession.logon(myDomain, NTLMAuth);
    // after loging in, here's how to get the SID for the Domain
    jcifs.smb.SID mySid = jcifs.smb.SID.getServerSid(hostName, NTLMAuth);
  // this returns something like 
  // Sid Domain SID: S-1-5-21-796745780-2711697408-451074171
  // trying to resolve SIDs this way DOES NOT work
  SID[] sids = new SID[10];
    sids[0] = mySid; // assigns domain SID???
    jcifs.smb.SID.resolveSids(hostName, NTLMAuth, sids);
    for (int i = 0; i < sids.length; i++ ) {
	    System.out.println("Sids["+i+"] Type: " +sids[i].getType());
  } catch (SmbException smbe) {
	  System.out.println("Failed to Authenticate: "+smbe.getMessage()+" NTStatus:
  } catch (Exception e) {
	  System.out.println("Failed to Authenticate: "+e.getMessage());

More information about the jcifs mailing list