oc 6.0.0a: if user ldap dn changes, user cant log in.
OC6.0.0a. Users are fetched from ldap (AD) backend. Users logs into oc service and his/her information is written to mysql database (oc_ldap_user_mapping).
example DN in LDAP and in OC mysql database: cn=user name,ou=it,ou=employee,dc=example,dc=com
Now user moves inside organisation and dn changes. DN in LDAP: cn=user name,ou=finance,ou=employee,dc=example,dc=com
OC mysql database contains old dn: cn=user name,ou=it,ou=employee,dc=example,dc=com
User is not able to log on and wrong password error is displayed/generated.
@blizzz
Is the UUID set for this user in the database? What is set as "UUID Attribute for Users" (if not default)?
UUID is "auto".
mysql> select * from oc_ldap_user_mapping where ldap_dn like "%user name%"\G *************************** 1. row *************************** ldap_dn: cn=user name,ou=it,ou=employee,dc=example,dc=com owncloud_name: DA07C6F1-F664-4910-9DF0-E87243C1287A directory_uuid: DA07C6F1-F664-4910-9DF0-E87243C1287A 1 row in set (0.00 sec)
Can you confirm that the UUID stayed the same for the user and did not change, unlike the DN?
I can confirm, that UUID did not change in LDAP (AD): objectGUID atribute contains same value. See screenshot

I tried to reproduce it, works for me though (i.e. new DN is recognized).
Maybe the old cache was in place. Did you try again after some time (>10 minutes by default)?
There was couple of days between dn change and login attempt. For me fix is just to update ldap_dn value and then user is instantly able to log in. Tried several times with my own account.
Sure, this however should happen automatically in the background without any admin involvement.
Do I understand correctly, when you try it with your account you can confirm the behaviour as reported by your user?
Yes. I can confirm this behaviour.
Another question: can you confirm that the new DN is included in the Base (User) DN?
Can you please make sure that your debugging level includes "Info" (bottom of the admin page), try to login when the DN is changed and see whether you find a message like "Cannot determine UUID for $dn. Skipping." in the log? (The log can be access in data/owncloud.log too).
Now. Moving my own account to somewhere else in AD.
Debug level: info Jan 15 09:00:23 oc_server ownCloud[35992]: {core} Login failed: user 'username' , wrong password, IP:client_IP
Debug level: all Jan 15 09:00:45 oc_server ownCloud[18167]: {core} Login failed: user 'username' , wrong password, IP:client_IP
I set up openldap proxy between OC and AD so i can have better overview what's going on on server side: Logs from ldap proxy:
Jan 15 09:04:19 openldap slapd[851]: conn=1034175 fd=38 ACCEPT from IP=OC_SERVER_IP:35378 (IP=0.0.0.0:636) Jan 15 09:04:19 openldap slapd[851]: conn=1034175 fd=38 TLS established tls_ssf=256 ssf=256 Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=0 BIND dn="cn=oc-auth,cn=Users,dc=example,dc=com" method=128 Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=0 BIND dn="cn=oc-auth,cn=Users,dc=example,dc=com" mech=SIMPLE ssf=0 Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=0 RESULT tag=97 err=0 text= Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=1 SRCH base="ou=employee,dc=example,dc=com" scope=2 deref=0 filter="(&(objectClass=person)(|(?SAMACCOUNTNAME=username)(mail=username))(|(?MEMBEROF=cn=employees,ou=Groups,ou=employee,dc=example,dc=com)(?MEMBEROF=cn=guests,ou=Groups,ou=employee,dc=example,dc=com)))" Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=1 SRCH attr=dn Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=1 SEARCH RESULT tag=101 err=0 nentries=1 text= Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=2 SRCH base="cn=cn=user name,ou=finance,ou=employee,dc=example,dc=com" scope=0 deref=0 filter="(objectClass=)" Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=2 SRCH attr=auto Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=2: non-critical control "1.2.840.113556.1.4.1339" not supported; stripped. Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=2 SEARCH RESULT tag=101 err=0 nentries=1 text= Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=3 SRCH base="cn=cn=user name,ou=finance,ou=employee,dc=example,dc=com" scope=0 deref=0 filter="(objectClass=)" Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=3 SRCH attr=entryuuid Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=3: non-critical control "1.2.840.113556.1.4.1339" not supported; stripped. Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=3 SEARCH RESULT tag=101 err=0 nentries=1 text= Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=4 SRCH base="cn=cn=user name,ou=finance,ou=employee,dc=example,dc=com" scope=0 deref=0 filter="(objectClass=)" Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=4 SRCH attr=nsuniqueid Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=4: non-critical control "1.2.840.113556.1.4.1339" not supported; stripped. Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=4 SEARCH RESULT tag=101 err=0 nentries=1 text= Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=5 SRCH base="cn=cn=user name,ou=finance,ou=employee,dc=example,dc=com" scope=0 deref=0 filter="(objectClass=)" Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=5 SRCH attr=objectguid Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=5: non-critical control "1.2.840.113556.1.4.1339" not supported; stripped. Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=5 SEARCH RESULT tag=101 err=0 nentries=1 text= Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=6 SRCH base="cn=cn=user name,ou=finance,ou=employee,dc=example,dc=com" scope=0 deref=0 filter="(objectClass=*)" Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=6 SRCH attr=auto Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=6: non-critical control "1.2.840.113556.1.4.1339" not supported; stripped. Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=6 SEARCH RESULT tag=101 err=0 nentries=1 text= Jan 15 09:04:19 openldap slapd[851]: conn=1034175 op=7 UNBIND Jan 15 09:04:19 openldap slapd[851]: conn=1034175 fd=38 closed
Moving my account back to original place and example of successful login:
Jan 15 09:06:02 openldap slapd[851]: conn=1034186 fd=45 ACCEPT from IP=OC_SERVER_IP:12246 (IP=0.0.0.0:636) Jan 15 09:06:02 openldap slapd[851]: conn=1034186 fd=45 TLS established tls_ssf=256 ssf=256 Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=0 BIND dn="cn=oc-auth,cn=Users,dc=example,dc=com" method=128 Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=0 BIND dn="cn=oc-auth,cn=Users,dc=example,dc=com" mech=SIMPLE ssf=0 Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=0 RESULT tag=97 err=0 text= Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=1 SRCH base="ou=employee,dc=example,dc=com" scope=2 deref=0 filter="(&(objectClass=person)(|(?SAMACCOUNTNAME=username)(mail=username))(|(?MEMBEROF=cn=employees,ou=Groups,ou=employee,dc=example,dc=com)(?MEMBEROF=cn=guests,ou=Groups,ou=employee,dc=example,dc=com)))" Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=1 SRCH attr=dn Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=1 SEARCH RESULT tag=101 err=0 nentries=1 text= Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=2 SRCH base="cn=user name,ou=it,ou=employee,dc=example,dc=com" scope=0 deref=0 filter="(objectClass=)" Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=2 SRCH attr=mail Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=2: non-critical control "1.2.840.113556.1.4.1339" not supported; stripped. Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=2 SEARCH RESULT tag=101 err=0 nentries=1 text= Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=3 BIND anonymous mech=implicit ssf=0 Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=3 BIND dn="cn=user name,ou=it,ou=employee,dc=example,dc=com" method=128 Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=3 BIND dn="cn=user name,ou=it,ou=employee,dc=example,dc=com" mech=SIMPLE ssf=0 Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=3 RESULT tag=97 err=0 text= Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=4 BIND anonymous mech=implicit ssf=0 Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=4 BIND dn="cn=user name,ou=it,ou=employee,dc=example,dc=com" method=128 Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=4 BIND dn="cn=user name,ou=it,ou=employee,dc=example,dc=com" mech=SIMPLE ssf=0 Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=4 RESULT tag=97 err=0 text= Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=5 SRCH base="cn=user name,ou=it,ou=employee,dc=example,dc=com" scope=0 deref=0 filter="(objectClass=)" Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=5 SRCH attr=jpegPhoto Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=5: non-critical control "1.2.840.113556.1.4.1339" not supported; stripped. Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=5 SEARCH RESULT tag=101 err=0 nentries=1 text= Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=6 SRCH base="cn=user name,ou=it,ou=employee,dc=example,dc=com" scope=0 deref=0 filter="(objectClass=)" Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=6 SRCH attr=1.1 Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=6: non-critical control "1.2.840.113556.1.4.1339" not supported; stripped. Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=6 SEARCH RESULT tag=101 err=0 nentries=1 text= Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=7 SRCH base="cn=user name,ou=it,ou=employee,dc=example,dc=com" scope=0 deref=0 filter="(objectClass=)" Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=7 SRCH attr=cn Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=7: non-critical control "1.2.840.113556.1.4.1339" not supported; stripped. Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=7 SEARCH RESULT tag=101 err=0 nentries=1 text= Jan 15 09:06:02 openldap slapd[851]: conn=1034186 op=8 UNBIND Jan 15 09:06:02 openldap slapd[851]: conn=1034186 fd=45 closed Jan 15 09:06:02 openldap slapd[851]: conn=1034187 fd=45 ACCEPT from IP=OC_SERVER_IP:24624 (IP=0.0.0.0:636) Jan 15 09:06:02 openldap slapd[851]: conn=1034187 fd=45 TLS established tls_ssf=256 ssf=256 Jan 15 09:06:02 openldap slapd[851]: conn=1034187 op=0 BIND dn="cn=oc-auth,cn=Users,dc=example,dc=com" method=128 Jan 15 09:06:02 openldap slapd[851]: conn=1034187 op=0 BIND dn="cn=oc-auth,cn=Users,dc=example,dc=com" mech=SIMPLE ssf=0 Jan 15 09:06:02 openldap slapd[851]: conn=1034187 op=0 RESULT tag=97 err=0 text= Jan 15 09:06:02 openldap slapd[851]: conn=1034187 op=1 SRCH base="ou=groups,ou=employee,dc=example,dc=com" scope=2 deref=0 filter="(&(&(|(?objectClass=GROUP)))(member=cn=user name,ou=it,ou=employee,dc=example,dc=com))" Jan 15 09:06:02 openldap slapd[851]: conn=1034187 op=1 SRCH attr=name dn Jan 15 09:06:02 openldap slapd[851]: conn=1034187 op=1 SEARCH RESULT tag=101 err=0 nentries=4 text= Jan 15 09:06:02 openldap slapd[851]: conn=1034187 op=2 UNBIND Jan 15 09:06:02 openldap slapd[851]: conn=1034187 fd=45 closed
Thank you for the details! And very interesting.
Debug level: info
Jan 15 09:00:23 oc_server ownCloud[35992]: {core} Login failed: user 'username' , wrong password, IP:client_IP
Tells us that UUID and DN should be known. Can you please check which row the database tables oc_ldap_user_mapping returns for directory_uuid = your UUID?
The other thing that hits me is that when looking for the UUID all possible attributes are tested (so far ok) but it does not stop after the correct objectguid. If it does not exist, reading 'guid' should be attempted, however we look for 'auto'. Not what should happen. But I do not think it is a cause here.
Then you see in the log
non-critical control "1.2.840.113556.1.4.1339" not supported
which refers to http://msdn.microsoft.com/en-us/library/windows/desktop/aa366979%28v=vs.85%29.aspx
This is interesting, because I cannot say whether this is very bad or does not play a role. We need to disable referrals otherwise search operation may fail. By default it is not a problem with AD, is it likely that this is enforced somehow in your AD?
Ups. Sry. My bad. Tried to cancel comment i was wrinting. Anyhow. In the meantime i trashed my oc server :) I try to set up test environment so real users are not affected.
Referrals seems to be not important. Previously i used port 3269 to communicate with AD. Configured to use port 636 and it behaves in same way. Unsuccessful logins are not seen in EventViewer (or i can't find them as i can with openldap). Successful logins (account in original ou) are logged and can be seen in EventViewer.
So. With or without ldap proxy, with or without referrals, if i move account to another ou, i'm unable to log in OC and wrong password warning is generated. UUID does not change during move nor group belongings.
Server is Win 2008R2 and AD functional and forest levels are 2008R2.
Could you please apply following patch, retry a login with the new DN and post the owncloud.log file? These are just debug messages but should help to narrow down the faulty thing.
diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php
index 72f9c74..518418d 100644
--- a/apps/user_ldap/lib/access.php
+++ b/apps/user_ldap/lib/access.php
@@ -262,6 +262,7 @@ class Access extends LDAPUtility {
//with the group support, check whether the provided DN matches one of
//the given Bases
if(!$this->isDNPartOfBase($dn, $this->connection->ldapBaseUsers)) {
+ \OCP\Util::writeLog('user_ldap', 'provided DN is not part of BaseDN.', \OCP\Util::INFO);
return false;
}
@@ -290,11 +291,13 @@ class Access extends LDAPUtility {
//let's try to retrieve the ownCloud name from the mappings table
$ocname = $this->$fncFindMappedName($dn);
if($ocname) {
+ \OCP\Util::writeLog('user_ldap', 'ocname for DN '.$dn.' is '.$ocname, \OCP\Util::INFO);
return $ocname;
}
//second try: get the UUID and check if it is known. Then, update the DN and return the name.
$uuid = $this->getUUID($dn, $isUser);
+ \OCP\Util::writeLog('user_ldap', 'UUID for DN '.$dn.' is '.$uuid, \OCP\Util::INFO);
if($uuid) {
$query = \OCP\DB::prepare('
SELECT `owncloud_name`
@@ -302,6 +305,7 @@ class Access extends LDAPUtility {
WHERE `directory_uuid` = ?
');
$component = $query->execute(array($uuid))->fetchOne();
+ \OCP\Util::writeLog('user_ldap', 'Outdated DN detected', \OCP\Util::INFO);
if($component) {
$query = \OCP\DB::prepare('
UPDATE `'.$table.'`
@@ -309,6 +313,7 @@ class Access extends LDAPUtility {
WHERE `directory_uuid` = ?
');
$query->execute(array($dn, $uuid));
+ \OCP\Util::writeLog('user_ldap', 'Current DN stored. ocname is '.$component, \OCP\Util::INFO);
return $component;
}
} else {
@@ -318,19 +323,23 @@ class Access extends LDAPUtility {
}
if(is_null($ldapname)) {
+ \OCP\Util::writeLog('user_ldap', 'Attempt to read name attribute "'.$nameAttribute.'" for DN '.$dn, \OCP\Util::INFO);
$ldapname = $this->readAttribute($dn, $nameAttribute);
if(!isset($ldapname[0]) && empty($ldapname[0])) {
\OCP\Util::writeLog('user_ldap', 'No or empty name for '.$dn.'.', \OCP\Util::INFO);
return false;
}
$ldapname = $ldapname[0];
+ \OCP\Util::writeLog('user_ldap', 'Attribute found, value: '.$ldapname, \OCP\Util::INFO);
}
if($isUser) {
$usernameAttribute = $this->connection->ldapExpertUsernameAttr;
if(!emptY($usernameAttribute)) {
+ \OCP\Util::writeLog('user_ldap', 'Custom user name attribute: '.$usernameAttribute, \OCP\Util::INFO);
$username = $this->readAttribute($dn, $usernameAttribute);
$username = $username[0];
+ \OCP\Util::writeLog('user_ldap', 'Custom attribute found, value: '.$username, \OCP\Util::INFO);
} else {
$username = $uuid;
}
@@ -338,6 +347,7 @@ class Access extends LDAPUtility {
} else {
$intname = $ldapname;
}
+ \OCP\Util::writeLog('user_ldap', 'Internal name: '.$intname, \OCP\Util::INFO);
//a new user/group! Add it only if it doesn't conflict with other backend's users or existing groups
//disabling Cache is required to avoid that the new user is cached as not-existing in fooExists check
diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php
index a19af86..a287515 100644
--- a/apps/user_ldap/user_ldap.php
+++ b/apps/user_ldap/user_ldap.php
@@ -154,6 +154,7 @@ class USER_LDAP extends BackendUtility implements \OCP\UserInterface {
return false;
}
$dn = $ldap_users[0];
+ \OCP\Util::writeLog('user_ldap', 'Login attempt with DN: '.$dn, \OCP\Util::INFO);
//do we have a username for him/her?
$ocname = $this->access->dn2username($dn);
@@ -165,6 +166,7 @@ class USER_LDAP extends BackendUtility implements \OCP\UserInterface {
//are the credentials OK?
if(!$this->access->areCredentialsValid($dn, $password)) {
+ \OCP\Util::writeLog('user_ldap', 'Login failed, invalid credentials', \OCP\Util::INFO);
return false;
}
@@ -175,7 +177,7 @@ class USER_LDAP extends BackendUtility implements \OCP\UserInterface {
//give back the display name
return $ocname;
}
-
+ \OCP\Util::writeLog('user_ldap', 'Login failed, could not determine ocname', \OCP\Util::INFO);
return false;
}
I'm a bit surprised. I set debug level to all from web admin interface. Moved my account to another ou and tried to log in. But only this is appearing in log:
Jan 17 09:34:13 oc-test ownCloud[1512]: {core} Login failed: user 'usename' , wrong password, IP:client_ip
Sorry, have had a longer time-out.
How about totally new users, can they login?
In the mean time i updated our owncloud server to 6.0.1
Created test user in the same ou i'm located and surprise - i can not log in using this account.
@boune seems to have the same issue, for the record https://github.com/owncloud/core/issues/7090#issuecomment-34429893
I think I will ask you for some more debugging, give me a bit of time.
This looks exactly like what I was experiencing. I simply deleted the "auto" from both lines, leaving them blank, as described in Issue #7515 and it began working as expected.