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 
Is this actually required? - I don't see it used anywhere.