Moving from a Linux Mail Server and peer-to-peer network to Exchange Server 2007 (Part 2)

If you missed the other parts in this article series please read:





In this article we will create the e-mail Address Policy to be applied to the new users and we will create the users based on the Linux passwd file.

Creating the E-Mail Address Policy


We have a bunch of Linux distribution and MTA (Message Transfer Agents) out there, in this article we will move from Postfix to Exchange Server 2007. Each MTA has different configuration files but most of them use the passwd file and an alias file to gather information about the current environment. One of the pieces of information that we must know is how the current naming schema is being used. If they have the format [email protected] or [email protected], then our work will be easier because we are going to use this naming strategy in Exchange Server 2007 before creating the new mailboxes. If we don’t have a standard after creating the users we will have to validate each user to make sure that the e-mail addresses match between the environments.


Before creating the e-mail address policy we have to configure Exchange Server 2007 to accept the same external domains that we have configured in the Linux box. To configure the Accepted Domains in Exchange 2007 follow these steps:



  1. Open the Exchange Management Console.
  2. Expand Organization Configuration.
  3. Click on Hub Transport, and then click on the Accepted Domains tab.
  4. In Toolbox Actions, click on New Accepted Domain.
  5. Add a name for the new domain and fill in the Accept Domain field with the external name (Example: and click on New, as shown in Figure 01.


Figure 01: Adding accepted domains, all domains configured on the Linux box must be added in Exchange Server



  1. Click on Finish


Now, it’s time to create the E-mail Address policy to stamp the correct SMTP address on future users:



  1. Open the Exchange Management Console.
  2. Expand Organization Configuration, click on Hub Transport.
  3. Click on Default Policy and click on Edit at Toolbox Actions.
  4. Introduction. Just click Next.
  5. Conditions. Click on Next.
  6. E-Mail Address. Click on Add and we will be able to set up the format of the new SMTP address that will be used by new users. Choose a format that is currently being utilized by the Linux box and select the accepted domain list choosing the domain that we have just created. Click OK. See Figure 02.


Figure 02: Adding the new SMTP address format to be used in the mailboxes



  1. E-mail Address. We can add more than one SMTP format but we have to use only one as the Reply Address (Figure 03). Click on Next.
    We can create more than one name schema to better fit in our current environment, it can be useful if we have more than two standards in the current environment.



Figure 03: Defining the E-mail Address policies that will be applied to the mailboxes



  1. Schedule. Accept the default values and click on Next.
  2. Edit E-mail Address Policy. Click on Edit.
  3. Completion. Click on Finish.


Now all new users will receive an SMTP address in accordance with our new E-mail Address Policy. We must make sure that the SMTP address of the current Linux users will be the same in the new mailboxes.


Creating the Linux mailbox users as Active Directory mail-enabled users


We will be using PowerShell to create all Active Directory users and mailboxes, using a file that contains all user names in use by Linux:



  1. Copy the passwd file that is located on /etc/passwd from Linux to any computer with Excel installed.
  2. Rename passwd to passwd.csv and open it using Wordpad.
  3. Click on Edit, Replace and in the field Find what write “:” and in the field Replace with write “;”, and then click on Replace All.
  4. Save the file and close it.
  5. Now open the passwd.csv that we have just edited in Microsoft Excel.
  6. Let’s clean up the file to be used by PowerShell. Linux has a bunch of system accounts and we do not want these users in our Active Directory, right? So… all normal users have a uid (User ID) of 500 or higher. So we can now remove users with a uid (3rd column) of less than 500. We also need to replicate these changes in the passwd.csv file using Excel:
    – After using the uid information to remove unnecessary users we can remove all columns that we will not be used in Active Directory, such as password (2nd column), uid (3rd column), guid (4th column), dir and shell columns.
    – Right-click on row number 1, and click on Insert to create a new first blank row.
    – Head each column with a descriptive title. We will use it to create the user, mailboxes, and add extra information to the new users accounts. In this article we will create the following column titles: UserName, DisplayName, FirstName, LastName, Office, OfficePhone and HomePhone to match with information that we have in the Linux passwd file.


The CSV file after the cleanup process will look like Figure 04 below.


Figure 04: CSV file after the clean up process


Now, we can fill in the CSV file with user information and we can create additional columns to be imported into Active Directory as well (Figure 05).


Figure 05: Final CSV file with all current user information retrieved from the Linux box


Okay, we have just built the CSV file. It’s time to create the users through PowerShell.



  1. Copy the passwd.csv file to C:\ in the Exchange Server.
  2. Open the Exchange Management Shell.
  3. Import the CSV to a variable, using the following cmdlet:
    $FilePasswd = Import-Csv C:\passwd.csv
  4. To validate the content of the $FilePasswd variable (Figure 06), just type in:


Figure 06: The content of the variable $Passwdfile



  1. Let’s create an OU to create the new users. In this article we will use an OU called Postfix Users.
  2. We have to define an initial password to the new accounts that will be created through PowerShell, then type in the following cmdlet:
    $Password = Read-Host “Password “ –AsSecureString
    We will be requested for the password. We should use an easy password that will be used for all new accounts. The user will use this password the first time they log on to the Active Directory. We have to inform all users about the migration process and this initial password.
  3. Now that we have finished all the prerequisites required to create users (Figure 07), we can create the mailboxes using our imported CSV file through the $FilePasswd variable and the columns that we defined in Excel to match with the parameters used. The following table can be used to create the cmdlet to start the user creation process:




Cmdlet Parameter


Variable that will be used




CSV file imported (step 03)




Each line read of variable $FilePasswd will add the Username more @apatricio.local to the $UPN variable. We have to change using your current FQDN domain name used during AD deployment.


-Alias and -Name


$_.UserName that is the Username column of our CSV file.




It will be the value of $UPN variable that is changing for each user.




$_.DisplayName that is the DisplayName column in our CSV file.


-FirstName and -LastName


$_.FirstName and $_.Lastname that are the FirstName and LastName column in our CSV file respectively.




Database that the new users will create, to validate the mailbox database we can use run Get-MailboxDatabase.




OU where the new users will be created.




$Password that was created in step 6.




$True. All users after the first logon in the Active Directory will be requested to change their password.


Table 1


In our article the following cmdlet will be used:


$FilePasswd | ForEach { $UPN = $_.UserName + “apatricio.local”; New-Mailbox –Alias $_.UserName –Name $_userName –UserPrincipalName $UPN –DisplayName $_.DisplayName –FirstName $_.FirstName –LastName $_.LastName –Database “srv-2k7-ex01\mailbox database” –OrganizationUnit “PostFix Users” –Password $Password –ResetPasswordOnNextLogon $true }


Figure 07: Creating the new users through PowerShell cmdlet


Now we are able to open the Exchange Management Console and see the new mailbox that we have just created (Figure 08).


Figure 08: The new users created


In the process above we created all users from the Linux passwd file. If you are using the alias file you have to update those e-mail addresses in the current environment. If there is only a small number of e-mail addresses on the alias file the work can be done manually but in some cases a script to add the secondary SMTP address can be useful.




In this article we defined our E-mail address policy to match with the current policy that is being used in the Linux Box. We also created all users in the Active Directory and Exchange Server using the Linux passwd file as our source.


If you missed the other parts in this article series please read:



About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top