title: How to convert the SID to String and vice versa in Java?
body: <p>I'm writing a program in Java, using Spring-LDAP. I need to implement a method, which should search a user by SID. For this reason I use a filter like <code>"&amp;((objectClass=User)(objectSid="+sid+"))"</code>. The search doesn't work with sid in String format like <code>"S-1-12-345677-5676743-223344-..."</code>.</p>
  
  <p>Using Apache Directory Studio, I can query my AD LDAP database regulary using a filter like: <code>(objectSid=\ff\01\03\04\1a\2b\...)</code> successfully. Here is the objectSid in hexadecimal format.</p>
  
  <p>Now, how to translate the SID from String to hexadecimal and vice versa in a program, in Java?</p>