Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 974
  • Last Modified:

Obtain the user SID with JCIFs/NTLM?


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: "+smbe.getNtStatus());
		} catch (Exception e) {
			System.out.println("Failed to Authenticate: "+e.getMessage());

Open in new window

1 Solution
CarlosScheideckerAuthor Commented:
Used LDAP for the needs I have as per talk with JCIFs developers. Not want I wanted but did the trick.

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now