How to handle multiple domains

We're looking at using ejabberd as our IM solution for our company. We've got offices in several cities, with several domain names. We are using MySQL as our authentication method, and I've written a script that pulls usernames out of our Active Directory and puts them in MySQL. We don't want to authenticate LDAP off of our AD because we don't want people storing their actual domain credentials in their IM clients.

So, here's my question. In the users table in MySQL, there are fields for username and password, but not domain name. If the user Stephen Gilbert (username sgilbert@domain1) is working in one office, and the user Sarah Gilbert (username sgilbert@domain2) is working in another office, when they're added to the ejabberd server, they're both sgilbert. What is the preferred method for handling this type of conflict? My first thought is to append a unique qualifier to the end of the username, so the usernames would be like sgilbert_domain1 and sgilbert_domain2. Is this the way it's normally done, or is there a better solution?

Setup a database for each domain

Currently you have two domains, and you are using the same database for both domains?

{hosts, ["domain1", "domain2"]}.
{auth_method, [odbc]}.
{mysql, "Server", "Database", "Username", "Password"}.

I think you must setup a different database for each domain:

{hosts, ["domain1", "domain2"]}.
{auth_method, [odbc]}.

{host_config, "domain1", 
  [
    {mysql, "Server", "Database_domain1", "Username", "Password"}
  ]
}.

{host_config, "domain2", 
  [
    {mysql, "Server", "Database_domain2", "Username", "Password"}
  ]
}.

AH!

Gotcha! Thanks, that's exactly what I needed.

Syndicate content