Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,14 @@ protected boolean isUserDisabled(SearchResult result) throws NamingException {
}

protected String getMemberOfAttribute(final Long domainId) {
String rc;
if(_ldapConfiguration.isNestedGroupsEnabled(domainId)) {
return MICROSOFT_AD_NESTED_MEMBERS_FILTER;
rc = MICROSOFT_AD_NESTED_MEMBERS_FILTER;
} else {
return MICROSOFT_AD_MEMBERS_FILTER;
rc = MICROSOFT_AD_MEMBERS_FILTER;
}
logger.trace(“using memberOf filter = {} for domain with id {}”, rc, domainId);

return rc;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@

import com.cloud.utils.Pair;
import org.apache.cloudstack.ldap.dao.LdapConfigurationDao;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class LdapConfiguration implements Configurable{
private final static String factory = "com.sun.jndi.ldap.LdapCtxFactory";
protected Logger logger = LogManager.getLogger(getClass());

private static final ConfigKey<Long> ldapReadTimeout = new ConfigKey<Long>(
Long.class,
Expand Down Expand Up @@ -325,7 +328,7 @@ public LdapUserManager.Provider getLdapProvider(final Long domainId) {
try {
provider = LdapUserManager.Provider.valueOf(ldapProvider.valueIn(domainId).toUpperCase());
} catch (IllegalArgumentException ex) {
//openldap is the default
logger.warn("no LDAP provider found for domain {}, using openldap as default", domainId);
provider = LdapUserManager.Provider.OPENLDAP;
}
return provider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected LdapUser createUser(final SearchResult result, Long domainId) throws N
final String firstname = LdapUtils.getAttributeValue(attributes, _ldapConfiguration.getFirstnameAttribute(domainId));
final String lastname = LdapUtils.getAttributeValue(attributes, _ldapConfiguration.getLastnameAttribute(domainId));
final String principal = result.getNameInNamespace();
final List<String> memberships = LdapUtils.getAttributeValues(attributes, _ldapConfiguration.getUserMemberOfAttribute(domainId));
final List<String> memberships = LdapUtils.getAttributeValues(attributes, getMemberOfAttribute(domainId));

String domain = principal.replace("cn=" + LdapUtils.getAttributeValue(attributes, _ldapConfiguration.getCommonNameAttribute()) + ",", "");
domain = domain.replace("," + _ldapConfiguration.getBaseDn(domainId), "");
Expand All @@ -87,7 +87,7 @@ private String generateSearchFilter(final String username, Long domainId) {
usernameFilter.append((username == null ? "*" : LdapUtils.escapeLDAPSearchFilter(username)));
usernameFilter.append(")");

String memberOfAttribute = _ldapConfiguration.getUserMemberOfAttribute(domainId);
String memberOfAttribute = getMemberOfAttribute(domainId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DaanHoogland
there is a method in the same file

    protected String getMemberOfAttribute(final Long domainId) {
        return _ldapConfiguration.getUserMemberOfAttribute(domainId);
    }

which is used only once

        if ("GROUP".equals(type)) {
            memberOfFilter.append("(").append(getMemberOfAttribute(domainId)).append("=");
            memberOfFilter.append(name);
            memberOfFilter.append(")"); 
        }

is it correct ?

Copy link
Contributor Author

@DaanHoogland DaanHoogland Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but it is overloaded in the AD user manager, so at this point it is not known which one will be called.

StringBuilder ldapGroupsFilter = new StringBuilder();
// this should get the trustmaps for this domain
List<String> ldapGroups = getMappedLdapGroups(domainId);
Expand Down
Loading