import java.util.Optional;
import java.util.StringJoiner;
+import javax.naming.Context;
import javax.naming.InvalidNameException;
import javax.naming.NameNotFoundException;
import javax.naming.NamingEnumeration;
private LdapDirectoryDao directoryDao;
+ /** Whether the the directory has is authenticated via a service user. */
+ private boolean authenticated = false;
+
public AbstractLdapDirectory(URI uriArg, Dictionary<String, ?> props, boolean scoped) {
this.configProperties = new Hashtable<String, Object>();
for (Enumeration<String> keys = props.keys(); keys.hasMoreElements();) {
if (DirectoryConf.SCHEME_LDAP.equals(u.getScheme())
|| DirectoryConf.SCHEME_LDAPS.equals(u.getScheme())) {
directoryDao = new LdapDao(this);
+ authenticated = configProperties.get(Context.SECURITY_PRINCIPAL) != null;
} else if (DirectoryConf.SCHEME_FILE.equals(u.getScheme())) {
directoryDao = new LdifDao(this);
+ authenticated = true;
} else if (DirectoryConf.SCHEME_OS.equals(u.getScheme())) {
directoryDao = new OsUserDirectory(this);
+ authenticated = true;
// singleUser = true;
} else {
throw new IllegalArgumentException("Unsupported scheme " + u.getScheme());
for (int i = 0; i < segments.length; i++) {
String segment = segments[i];
// TODO make attr names configurable ?
- String attr = path.startsWith("accounts/")/* IPA */ ? LdapAttrs.cn.name() : LdapAttrs.ou.name();
+ String attr = getDirectory().getRealm().isPresent()/* IPA */ ? LdapAttrs.cn.name()
+ : LdapAttrs.ou.name();
if (parentRdn != null) {
if (getUserBaseRdn().equals(parentRdn))
attr = LdapAttrs.uid.name();
return disabled;
}
+ public boolean isAuthenticated() {
+ return authenticated;
+ }
+
public Rdn getUserBaseRdn() {
return userBaseRdn;
}