How do I create custom usernames?

Great job on virtualmin. I set my server up in mere moments using the on an ubuntu LAMPS server. I can’t believe the power of this stuff. Using the virtualmin api, I was able to write a wrapper for the and to migrate our old server websites (using rsync) and email clients (using imapsync) to virtualmin. I have hit a major snag, however. The virtualmin username is taken from the email name and domain, not allowing for custom usernames. While I think this is good practice to ensure unique usernames, my predecessor on the legacy system did not use a consistent strategy for creating usernames. They do not match the email address at all. Without the ability to create a custom username, I will be breaking our clients MS Outlook POP settings when I migrate their accounts. With around 1000 users to migrate, thats a lot of phone calls from not so savvy endusers. Got any ideas on how i can use virtualmin to support custom username creation?

Hmm. It sounds like you’re saying the problem you have at the moment is that Virtualmin is appending the domain name to the username.

If that’s what you mean, you can tell Virtualmin to not do that.

If you log into Virtualmin, click System Settings -> Module Config, then choose "Defaults for new Domains" in the dropdown, you can tweak "Include domain name in usernames" and "Domain name style in username".

Further, if you do want to keep the domain name there, you can choose how exactly it’s formatted by going into Server Templates -> Default Settings, choose “Mail for Domain”, and the last option listed there is “Format for usernames that include domain”.

Does that help?

Thanks for the reply, Eric. I did read the manual, and played with the interface enough to know how to change the domain name appends, etc. That is not the issue. I am migrating a legacy system. About 1200 users have existing POP accounts set up in Outlook. The usernames they were given were not derivatives of the email address, at least not in the sense that virtualmin expects. has a username of rjrdon. Even this convention is not consistent. My predecessor at this job was a bit random in enforcing such policy.

I tried adding additional lines to /etc/passwd and /etc/shadow to support an alternate username for the account. It does not pass the saslauth test. Is there a way to add the login info in such a way that outlook will login to a custom username? What would the command be to add it to the saslauth db? I think I may be close to a solution. I noticed that if you select as the "Default for new domains", it adds 2 entries into /etc/passwd and /etc/shadow. So there must be a way. I assume the double entry is because of the @ in the username is going to break stuff, and is not considered to be a good idea.

OOps. I forgot to restart saslauth and postfix after I made the entrys into /etc/passwd and /etc/shadow. It does indeed work. The only drawback is that the entry now shows in virtualmin as another user. Is there a way to suppress the display? If not, I will train the staff here to ignore those entrys.

Is there a way to suppress the display? If not, I will train the staff here to ignore those entrys.

Not really… We have some magic to suppress display of “user-domain” style names on systems that are using “user@domain.tld” style logins (because you end up with two users for each account on those systems). But nothing for arbitrary hiding of names (the same code could probably be tweaked, since I think it’s detecting multiple identical UIDs and displaying only the “preferred” name, but in this case, it’d have no idea how to “prefer” a name, I think).

I’ll ask Jamie to chime in on this thread. I suspect there’s a way to get what you’re after working. But I don’t know what it is. :wink:

If you want your usernames and email addresses to differ, I would suggest doing the following :

  1. Turn off automatic appending of domain names, at System Settings -> Module Config -> Defaults for new domains -> Include domain name in usernames? (select Only to avoid clash)

  2. When creating a user, enter their IMAP login as the username, and enter their email in the ‘Additional email addresses’ box.

Let us know if this works for you …