NC12.03 LDAP username changed from user to user_1234
Hello project members, till today I have had no problem with nextcloud at all. Thank you very much for this wonderful project.
Today however a user tells me that they received a quota notification to use more than 886% of their quota (!).
looking deeper into it I saw that
Actual behaviour
- the affected user comes from ldap (Active directory group import)
- the username in NC adminweb changed from user to user_0815 (4 arbitrary digit number)
- the quota of the affected user was custom before and gone now.
- not all ldap imported users are affected, around 3 of 4 are.
- local database users are not affected
Expected behaviour
- username stays always the same as it is unique.
- quota stays always the same
Server configuration
Operating system: Ubuntu 16.04.3 LTS
Web server: apache2 2.4.18-2ubuntu3.5
Database: mysql 5.7
PHP version: 7.0
Nextcloud version: (see Nextcloud admin page) 12.0.3
Updated from an older Nextcloud/ownCloud or fresh install: yes
Where did you install Nextcloud from: https://nextcloud.com/
Signing status:
Signing status
No errors have been found.
List of activated apps:
App list
Enabled:
- activity: 2.5.2
- admin_audit: 1.2.0
- bruteforcesettings: 1.0.2
- comments: 1.2.0
- dav: 1.3.0
- federatedfilesharing: 1.2.0
- federation: 1.2.0
- files: 1.7.2
- files_sharing: 1.4.0
- files_texteditor: 2.4.1
- files_trashbin: 1.2.0
- files_versions: 1.5.0
- files_videoplayer: 1.1.0
- firstrunwizard: 2.1
- gallery: 17.0.0
- logreader: 2.0.0
- lookup_server_connector: 1.0.0
- nextcloud_announcements: 1.1
- notifications: 2.0.0
- oauth2: 1.0.5
- password_policy: 1.2.2
- provisioning_api: 1.2.0
- quota_warning: 1.1.1
- serverinfo: 1.2.0
- sharebymail: 1.2.0
- systemtags: 1.2.0
- theming: 1.3.0
- twofactor_backupcodes: 1.1.1
- updatenotification: 1.2.0
- user_ldap: 1.2.1
- workflowengine: 1.2.0
Disabled:
- encryption
- files_external
- files_pdfviewer
- survey_client
- user_external
Nextcloud configuration:
Config report
{
"system": {
"instanceid": "oci1s4xtq5qy",
"passwordsalt": "***REMOVED SENSITIVE VALUE***",
"secret": "***REMOVED SENSITIVE VALUE***",
"trusted_domains": [
"owncloud.manroland-web.com"
],
"datadirectory": "\/data\/owncloud",
"overwrite.cli.url": "https:\/\/owncloud.manroland-web.com",
"dbtype": "mysql",
"version": "12.0.3.3",
"dbname": "owncloud",
"dbhost": "localhost",
"dbtableprefix": "oc_",
"dbuser": "***REMOVED SENSITIVE VALUE***",
"dbpassword": "***REMOVED SENSITIVE VALUE***",
"installed": true,
"proxy": "192.168.56.254:8000",
"ldapIgnoreNamingRules": false,
"ldapUserCleanupInterval": "20",
"forcessl": true,
"trashbin_retention_obligation": "30, auto",
"logfile": "\/data\/owncloud\/nextcloud.log",
"forceSSLforSubdomains": true,
"mail_from_address": "noreply",
"mail_smtpmode": "php",
"mail_domain": "manroland-web.com",
"maintenance": false,
"theme": "",
"memcache.local": "\\OC\\Memcache\\Redis",
"redis": {
"host": "localhost",
"port": 6379
},
"memcache.locking": "\\OC\\Memcache\\Redis",
"appstore.experimental.enabled": false,
"updatechecker": false,
"htaccess.RewriteBase": "\/",
"ldapProviderFactory": "\\OCA\\User_LDAP\\LDAPProviderFactory",
"updater.release.channel": "stable",
"loglevel": 1
}
}
Are you using encryption: yes/no no encryption Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...
LDAP configuration
LDAP config
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Configuration | s01 |
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| hasMemberOfFilterSupport | 1 |
| hasPagedResultSupport | |
| homeFolderNamingRule | attr:sAMAccountname |
| lastJpegPhotoLookup | 0 |
| ldapAgentName | CN=g-svcowncloud,OU=Service-Accounts,OU=Users,OU=_GlobalObjects,OU=_Organisation,dc=mrws,dc=biz |
| ldapAgentPassword | *** |
| ldapAttributesForGroupSearch | |
| ldapAttributesForUserSearch | |
| ldapBackupHost | |
| ldapBackupPort | |
| ldapBase | dc=mrws,dc=biz |
| ldapBaseGroups | DC=mrws,DC=biz |
| ldapBaseUsers | DC=mrws,DC=biz |
| ldapCacheTTL | 600 |
| ldapConfigurationActive | 1 |
| ldapDefaultPPolicyDN | |
| ldapDynamicGroupMemberURL | |
| ldapEmailAttribute | mail |
| ldapExperiencedAdmin | 0 |
| ldapExpertUUIDGroupAttr | |
| ldapExpertUUIDUserAttr | sAMAccountname |
| ldapExpertUsernameAttr | sAMAccountname |
| ldapGidNumber | gidNumber |
| ldapGroupDisplayName | cn |
| ldapGroupFilter | |
| ldapGroupFilterGroups | |
| ldapGroupFilterMode | 1 |
| ldapGroupFilterObjectclass | |
| ldapGroupMemberAssocAttr | uniqueMember |
| ldapHost | ausdc01.mrws.biz |
| ldapIgnoreNamingRules | |
| ldapLoginFilter | (&(&(|(objectclass=person))(|(|(memberof=CN=AU-AP-CloudAuth,OU=LDAPAuth-Groups,OU=Groups,OU=AU,OU=_Organisation,DC=mrws,DC=biz)(primaryGroupID=7632))))(samaccountname=%uid)) |
| ldapLoginFilterAttributes | |
| ldapLoginFilterEmail | 0 |
| ldapLoginFilterMode | 1 |
| ldapLoginFilterUsername | 1 |
| ldapNestedGroups | 0 |
| ldapOverrideMainServer | 0 |
| ldapPagingSize | 500 |
| ldapPort | 389 |
| ldapQuotaAttribute | |
| ldapQuotaDefault | |
| ldapTLS | 0 |
| ldapUserDisplayName | displayname |
| ldapUserDisplayName2 | |
| ldapUserFilter | (&(|(objectclass=person))(|(|(memberof=CN=AU-AP-CloudAuth,OU=LDAPAuth-Groups,OU=Groups,OU=AU,OU=_Organisation,DC=mrws,DC=biz)(primaryGroupID=7632)))) |
| ldapUserFilterGroups | AU-AP-CloudAuth |
| ldapUserFilterMode | 1 |
| ldapUserFilterObjectclass | person |
| ldapUuidGroupAttribute | auto |
| ldapUuidUserAttribute | auto |
| turnOffCertCheck | 0 |
| turnOnPasswordChange | 0 |
| useMemberOfToDetectMembership | 1 |
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
cc @nextcloud/ldap
further information: shared folders and permissions disappeared as well for affected accounts :-(
the username in NC adminweb changed from user to user_0815 (4 arbitrary digit number)
nah, the user name does not change, but a different user was created. the suffix was appended, because to avoid a collision with an existing username.
The underlying reason is that the login of the user yielded a different LDAP record than originally. Typically, users are identified by the LDAP DN, and the detection of changed DNs relies on the UUID value (or if it is overridden).
The underlying reason is that the login of the user yielded a different LDAP record than originally. Typically, users are identified by the LDAP DN, and the detection of changed DNs relies on the UUID value (or if it is overridden).
sorry, but nack. neither UUID nor sth. else changed on these accounts. @blizzz I have overriden the default DN to rely on the sAMAccountname which didn´t change either.
By the way - the user seems to be a different/new one regarding their shares and permissions but they have their old directories. This behaviour is not consistent.
Can you help me to
- fix the actual problem
- prevent the problme from happening again?
Thanks, Claudio
@cklabautermann can you check and post the ldap_user_mappings table, where owncloud_name like "user%"?
@blizzz here you are: +-------------------------------------------------------------------------------------------+---------------+--------------------------------------+ | ldap_dn | owncloud_name | directory_uuid | +-------------------------------------------------------------------------------------------+---------------+--------------------------------------+ | cn=ln, sn,ou=mrws,ou=normal-users,ou=users,ou=au,ou=_organisation,dc=mrws,dc=biz | arabei | 629003CD-6D38-440B-B0F1-3A8F4EFB518E | | cn=ln, sn,ou=normal-users,ou=users,ou=au,ou=_organisation,dc=mrws,dc=biz | arabei_9892 | arabei | +-------------------------------------------------------------------------------------------+---------------+--------------------------------------+
I can´t figure out what has happened 3 days ago. some users are affected others are not.
@blizzz it seems as if nextcloud created a new object due to movement of the user object within ldap. this should not have happened if nextcloud ldap relies on UUID (or in my case sAMAccountname).
@cklabautermann yes, and the movement was not recognized, beacuse the UUID attribute was changed in production:
Changes will have effect only on newly mapped (added) LDAP users and groups.
→ go maintenance mode → do a backup → update original rows with the up-to-date DN and UUID value → remove the _1234-like rows → if applicable, clear $memcache → turn off maintenance mode
@blizzz but how can this happen at all? Even if the UUID of a user changed I still have configured the sAMAccountname to be my primal identifier. If I follow the steps recommended by you I am not safe to suffer the same thing again.......?

@cklabautermann the UUID is fetched and stored when the user is read for the first time from LDAP.
Anyone can help me understanding why my usernames changed although I took the sAMAccountname as the identifier for nextcloud users and they didn´t change at all? Please see settings in picture on entry above.
I would like to have a solution which fixes my problems and makes them stay away...
Thank you in advance.
@cklabautermann look, despite this not being a support portal I explained you how and why it happened and showed you a way to correct this in your case. While I agree this is not the best experienced, it works how it is documented. Therefore, I am closing this issue.
Of course you are free to discuss your problem and to proceed with it further on the forums https://help.nextcloud.com/
@blizzz thank you for your help. However I think this problem is a real bug. Of course I could follow your fix but the next time an existing user moves from one ou to another they would result in a new nextcloud account. And I thought this is the right place to deal with bugs and issues.
Of course I could follow your fix but the next time an existing user moves from one ou to another they would result in a new nextcloud account.
No, that's not the case. The move will be detected. It was not detected in your case, because the UUID attribute was changed in production (i.e. with users already being mapped) and the old value, bound to another attribute, was assigned to the user.
And I thought this is the right place to deal with bugs and issues.
Yes, and it was totally OK to open it here, and while I agree it does not work most comfortable it works like "advertised". Also I acknowledge, there is room for improvement, but it's not broken.
I did what you recommended and now users seem to be clean again. I hope this does not happen again when user´s OU changes again.......
We are facing the same issue, that suddenly user names get appended a _1234 number. We did NOT change the OU or the UUID.
Our users log in with SAML and get all user parameters from LDAP, the common UID is the unique e-mail address, which never changed.
@rasos : are you running the same NC release as I did then (12.03)? It would be nice to know whether this has been fixed in recent releases.
@cklabautermann we are on NC 13.05. We have looked into the code and found a very mysterious loop:
private function _createAltInternalOwnCloudNameForUsers($name) {
$attempts = 0;
//while loop is just a precaution. If a name is not generated within
//20 attempts, something else is very wrong. Avoids infinite loop.
while($attempts < 20){
$altName = $name . '_' . rand(1000,9999);
if(!$this->ncUserManager->userExists($altName)) {
return $altName;
}
$attempts++;
}
return false;
}
So it seems to to minimize some risk that this user really not already exists. This seems to be a workaround for an unsolved race condition (user still in memcache?). Any other idea?
Analysed source file: https://github.com/nextcloud/server/blob/95857a81cf5da88392b0abe7308e3e0b5299a056/apps/user_ldap/lib/Access.php#L760
We have the same issue here (NC 15.0.4). Is there any way to prevent the generation of these fake users? Did anyone find out why this happens?