private ISessionManager getSessionManagerUser(String username)
throws RepositoryException {
// Login tickets fail for superusers if restrict_su_ticket_login
// is set to T in the server config object. This code at least
// allows the configured superuser to perform searches.
ISessionManager sessionManagerUser;
String currentUsername = sessionManager.getIdentity(docbase).getUser();
if (username.equals(currentUsername)) {
if (logger.isLoggable(Level.FINE))
logger.fine("Using current session manager for " + username);
sessionManagerUser = sessionManager;
} else {
if (logger.isLoggable(Level.FINE))
logger.fine("Creating new session manager for " + username);
String ticket;
ISession session = sessionManager.getSession(docbase);
try {
ticket = session.getLoginTicketEx(username, "docbase", 0, false, null);
} finally {
sessionManager.release(session);
}
sessionManagerUser = clientX.getLocalClient().newSessionManager();
ILoginInfo loginInfo = clientX.getLoginInfo();
loginInfo.setUser(username);
loginInfo.setPassword(ticket);
sessionManagerUser.setIdentity(docbase, loginInfo);
}
return sessionManagerUser;
}