title: Getting a JackrabbitSession object from a JCR session object
body: <p>My goal is to get a JackrabbitSession from a JCR session in a standalone java application. I spent hours on it but can't find a working example.</p>
  
  <p>A few post like <a href="https://stackoverflow.com/questions/16580283/user-permissions-api-in-cq">this one</a> for example are implying it is possible to cast from a JCR session to a JackrabbitSession as follows but it actually does not work and throws a ClassCastException.</p>
  
  <pre><code>Repository repository = JcrUtils.getRepository("http://localhost:4502/crx/server");
  session = repository.login( new SimpleCredentials("admin", "admin".toCharArray()), "crx.default");
  
  JackrabbitSession js = (JackrabbitSession) session;
  final UserManager userManager = session.getUserManager();
  final User user = userManager.createUser(userName, userName);
  session.save();
  </code></pre>
  
  <p>The reason I want the native JackrabbitSession is because as in the above code I want to access the UserManager object. In my use case the JCR repository resides in an AEM instance on which I would like to create/delete users.</p>
  
  <p>Thx in advance</p>