views:

58

answers:

1

I have an application that will handle a big number of users. The users are divided into 2 types: public and private. Furthermore the private users are comprised of two different companies (maybe even more in the future) and already have established usernames from a LDAP & active directories that will be used to pre-populate my application's user model. To avoid name clashes I'm thinking about implementing username namespaces by using a prefix.

for example:

  • _company1_user1
  • _company2_user1
  • _web_user1

I would like to implement this if possible by using django's user model application. Perhaps by inheriting and overriding the standard methods and adding a namespace argument.

+3  A: 

I would suggest using their email address as the username to uniquely identify them.

Benjamin Ortuzar
Yes, that's my fallback solution.
Roberto Rosario
Agreed, but note that you will need to increase the size of the 'username' field in the User model and also change its validation routine. We increased it to 75 characters. We also created a routine, NormalizeUsername(), that forces everything to lowercase and makes sure it *could* be a valid email address. This needs to be used in UserManager.create_user and in your authentication process. A bit of a pain, but their email address *tends* to be something people can remember (although not always).
Peter Rowell
'A bit of a pain' - yep, that's what I'm trying to avoid. Plus I would also need to find/implement/hack a LDAP, email based authentication backend.
Roberto Rosario