1) Replace the deprecated unit test method.
2) Wraps filter usage in a list call.
3) Converts the old metaclass syntax to new.
4) Use range instead of xrange method.
5) Change Unicode to str.
6) Several other transformations.
7) Fixed change password test cases.
8) Use simplejson instead of plain JSON.
- Refactor functions to not always return the same value.
- Rename "cls" to "self" or add the missing "self" parameter.
- Remove useless assignment to variables.
Ensure error should be handled properly when LDAP user is created with the same name. Fixes#5420
Fixed an issue where an internal user is not created if the authentication source is set to internal and ldap. Fixes#5432
function, but - methods. Hence - 'self' should be used, and not 'cls'.
Also - use a constant for duplicate string literal in LDAP
authentication implementation.