Skip to content

Commit f434f50

Browse files
committed
Merge pull request #1485 from remibergsma/fix-ldap-default-domain
Set default networkDomain to empty instead of usernameThe 10th field of `createUserAccount` is `networkDomain` (See `AccountService.java`) and it is set to a var named `admin`, which is the user name. So, the first user that is created in a domain that links to LDAP, creates the account within the domain, and sets the `networkDomain` field to the username. All next users are created in the same account. Then we have the situation that in domain SBP we have a user `rbergsma` that logs in first, gets an account created and then (unless you override) all VMs started in the SBP domain will have network domain `rbergsma`. That is highly confusing and not what is should be. The `linkDomainToLdap` api call has no `networkDomain` field, so I propose to make this field empty (set it to null). It's a sting and null / empty is allowed. One can also specify the networkDomain when creating a VPC and also there it is allowed to be null. When te networkDomain is needed (and is not set in the domain and not in the VPC) it is constructed by using `guest.domain.suffix` so there always is a networkDomain to be used. It makes more sense to manually set it on a domain level, or specify it on the VPC and in the final case end up with something that is clearly generated (like cs342cloud.local) rather than the username of someone else. * pr/1485: Set default networkDomain to empty instead of username Signed-off-by: Will Stevens <williamstevens@gmail.com>
2 parents 987e800 + 9e1859e commit f434f50

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LinkDomainToLdapCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public void execute() throws ServerApiException {
8282
if (account == null) {
8383
try {
8484
UserAccount userAccount = _accountService.createUserAccount(admin, "", ldapUser.getFirstname(), ldapUser.getLastname(), ldapUser.getEmail(), null,
85-
admin, Account.ACCOUNT_TYPE_DOMAIN_ADMIN, domainId, admin, null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), User.Source.LDAP);
85+
admin, Account.ACCOUNT_TYPE_DOMAIN_ADMIN, domainId, null, null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), User.Source.LDAP);
8686
response.setAdminId(String.valueOf(userAccount.getAccountId()));
8787
s_logger.info("created an account with name " + admin + " in the given domain " + domainId);
8888
} catch (Exception e) {

plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapAuthenticator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private void enableUserInCloudStack(UserAccount user) {
119119

120120
private void createCloudStackUserAccount(LdapUser user, long domainId, short accountType) {
121121
String username = user.getUsername();
122-
_accountManager.createUserAccount(username, "", user.getFirstname(), user.getLastname(), user.getEmail(), null, username, accountType, domainId, username, null,
122+
_accountManager.createUserAccount(username, "", user.getFirstname(), user.getLastname(), user.getEmail(), null, username, accountType, domainId, null, null,
123123
UUID.randomUUID().toString(), UUID.randomUUID().toString(), User.Source.LDAP);
124124
}
125125

0 commit comments

Comments
 (0)