Search in sources :

Example 11 with LdapUserResponse

use of org.apache.cloudstack.api.response.LdapUserResponse in project cloudstack by apache.

the class LdapListUsersCmd method filterLocalDomain.

/**
 * filter the list of ldap users. no users visible to the caller already in the domain specified should be in the returned list
 * @param input ldap response list of users
 * @return a list of ldap users not already in ACS
 */
public List<LdapUserResponse> filterLocalDomain(List<LdapUserResponse> input) {
    if (s_logger.isTraceEnabled()) {
        s_logger.trace("filtering local domain users");
    }
    final List<LdapUserResponse> ldapResponses = new ArrayList<LdapUserResponse>();
    String domainId = getCurrentDomainId();
    for (final LdapUserResponse user : input) {
        UserResponse cloudstackUser = getCloudstackUser(user);
        if (cloudstackUser == null || /*doesn't exist in cloudstack*/
        !domainId.equals(cloudstackUser.getDomainId()) || /* doesn't exist in this domain */
        !cloudstackUser.getUserSource().equalsIgnoreCase(User.Source.LDAP.toString())) /* is from another source */
        {
            ldapResponses.add(user);
        }
    }
    annotateUserListWithSources(ldapResponses);
    return ldapResponses;
}
Also used : UserResponse(org.apache.cloudstack.api.response.UserResponse) LdapUserResponse(org.apache.cloudstack.api.response.LdapUserResponse) ArrayList(java.util.ArrayList) LdapUserResponse(org.apache.cloudstack.api.response.LdapUserResponse)

Example 12 with LdapUserResponse

use of org.apache.cloudstack.api.response.LdapUserResponse in project cloudstack by apache.

the class LdapManagerImpl method createLdapUserResponse.

@Override
public LdapUserResponse createLdapUserResponse(final LdapUser user) {
    final LdapUserResponse response = new LdapUserResponse();
    response.setUsername(user.getUsername());
    response.setFirstname(user.getFirstname());
    response.setLastname(user.getLastname());
    response.setEmail(user.getEmail());
    response.setPrincipal(user.getPrincipal());
    response.setDomain(user.getDomain());
    return response;
}
Also used : LdapUserResponse(org.apache.cloudstack.api.response.LdapUserResponse)

Aggregations

LdapUserResponse (org.apache.cloudstack.api.response.LdapUserResponse)12 ArrayList (java.util.ArrayList)8 LdapUser (org.apache.cloudstack.ldap.LdapUser)6 ListResponse (org.apache.cloudstack.api.response.ListResponse)3 UserResponse (org.apache.cloudstack.api.response.UserResponse)3 Domain (com.cloud.domain.Domain)2 Test (org.junit.Test)2 DomainVO (com.cloud.domain.DomainVO)1 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 ResponseObject (org.apache.cloudstack.api.ResponseObject)1 ServerApiException (org.apache.cloudstack.api.ServerApiException)1 NoLdapUserMatchingQueryException (org.apache.cloudstack.ldap.NoLdapUserMatchingQueryException)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1