Ldap user cleanup master

Port to master of https://github.com/owncloud/core/pull/12643 (cf. details in that PR).

Compared to the straight port the changes for master are: 
14 files changed, 187 insertions(+), 156 deletions(-)
(not so little either).

Tests went fine for me. 

Please have a look @craigpg @jnfrmarks @MorrisJobke @LukasReschke @Xenopathic 

cc @MTRichards 
Probably working for you locally because you're relying on Ubuntu's most modern shipped PHPUnit version 3.7 ;-)