Github user borisroman commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1285#discussion_r48488856
  
    --- Diff: 
plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapAuthenticator.java
 ---
    @@ -111,19 +114,27 @@ public LdapAuthenticator(final LdapManager 
ldapManager, final UserAccountDao use
             return new Pair<Boolean, ActionOnFailedAuthentication>(result, 
action);
         }
     
    -    private void enableUserInCloudStack(UserAccount user) {
    -        if(user != null && 
(user.getState().equalsIgnoreCase(Account.State.disabled.toString()))) {
    +    private void enableUserInCloudStack(final UserAccount user) {
    +        if (user != null && 
user.getState().equalsIgnoreCase(Account.State.disabled.toString())) {
                 _accountManager.enableUser(user.getId());
             }
         }
     
    -    private void createCloudStackUserAccount(LdapUser user, long domainId, 
short accountType) {
    -        String username = user.getUsername();
    -        _accountManager.createUserAccount(username, "", 
user.getFirstname(), user.getLastname(), user.getEmail(), null, username, 
accountType, domainId, username, null,
    -                                          UUID.randomUUID().toString(), 
UUID.randomUUID().toString(), User.Source.LDAP);
    +    private void createCloudStackUserAccount(final LdapUser user, final 
long domainId, final short accountType) {
    +        final String username = user.getUsername();
    +        final Account account = 
_accountManager.getActiveAccountByName(ldapGroupName, domainId);
    +        if (account == null) {
    +            s_logger.info("Account (" + ldapGroupName + ") for LDAP group 
does not exist. Creating account and user (" + username + ").");
    +            _accountManager.createUserAccount(username, "", 
user.getFirstname(), user.getLastname(), user.getEmail(), null, ldapGroupName, 
accountType, domainId,
    +                            username, null, UUID.randomUUID().toString(), 
UUID.randomUUID().toString(), User.Source.LDAP);
    +        } else {
    +            s_logger.debug("Account (" + ldapGroupName + ") for LDAP group 
already exists not exist. Creating user (" + username + ").");
    --- End diff --
    
    @miguelaferreira The following seems a bit strange "for LDAP group already 
exists not exist"... Maybe something like this; "for LDAP group already exists, 
but the user doesn't exist"


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to