OS 10.9.1 Mail Setup via Configuration Profile and AD attributes

fabian_ulmrich
Contributor

Hi everybody,

I would like to setup Mail.app automatically via ConfigProfile and AD attributes but for a reason it is not working. My LDAP connection is working fine, all information like $REALNAME (Full Name), $USERNAME (sAMAccountName) and $EMAIL (mail) are pulled from AD correctly. If I put those $ATTRIBUTES into my user-level-profile, just $REALNAME is provided to Mail.app. Tried to play arround, setting new extension attributes to my AD and using the syntax described in CasperAdministratorGuide 9.2, but it still doesn't work.

Anyone experiencing the same problems and has it solved yet? Really appreciate for your help in advance.

Thanks,
Fab

2 REPLIES 2

charliwest
Contributor II

I have a config profile that works for this, could you made get some screen shots or show your config if you download it?

fabian_ulmrich
Contributor

Hi @dwest][/url

Haven't posted my solution yet. What I used to setup Mail.app isn't really a nice way but it worked.
I noticed that at the very first login of the user, nothing is setup for the current user. So I created all needed Mail files myself with a little login script. After the script has completed, you just can startup Mail and you should see a prompt to login the users mail password directly or you have to push the 'flash' button next to your Inbox folder on the left hand side of Mail.app.

Just wanted to share this. Maybe this helps others as well, although it's seriously not the best way to get that managed.

#!/bin/bash
# Setup Mail.app with for current user


# Variables
LoggedInUser=$(/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }')
FullUserName=$(dscacheutil -q user -a name ${LoggedInUser} | fgrep gecos | sed -e 's/.*gecos: (.*)/1/')
Mail="/Users/${LoggedInUser}/Library/Mail"
MailV2="/Users/${LoggedInUser}/Library/Mail/V2"
MailData="/Users/${LoggedInUser}/Library/Mail/V2/MailData"

# After first login we sleep 30s so every folders are created
sleep 20

# Creating Folders MailV2 and MailData to store Account.plist
logger "Creating Folder ${MailV2}"
mkdir   ${MailV2}
logger "Creating Folder ${MailData}"
mkdir   ${MailData}


logger "Creating Accounts.plist"
exec 3>/tmp/Accounts.plist

echo '<?xml version="1.0" encoding="UTF-8"?>' >&3
echo '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' >&3
echo '<plist version="1.0">' >&3
echo '<dict>' >&3
echo    '<key>DeliveryAccounts</key>' >&3
echo    '<array>' >&3
echo        '<dict>' >&3
echo            '<key>AccountType</key>' >&3
echo            '<string>SMTPAccount</string>' >&3
echo            '<key>ConfigureDynamically</key>' >&3
echo            '<true/>' >&3
echo            '<key>Hostname</key>' >&3
echo            '<string>smtp.yourcompany.com</string>' >&3 # set your SMTP Server details here
echo            '<key>PortNumber</key>' >&3
echo            '<integer>25</integer>' >&3
echo            '<key>SSLEnabled</key>' >&3
echo            '<string>YES</string>' >&3
echo            '<key>ShouldUserAuthentication</key>' >&3
echo            '<string>YES</string>' >&3
echo            '<key>UseDefaultPorts</key>' >&3
echo            '<string>YES</string>' >&3
echo            '<key>Username</key>' >&3
echo            "<string>${LoggedInUser}</string>" >&3 # Current user
echo        '</dict>' >&3
echo    '</array>' >&3
echo    '<key>MailAccounts</key>' >&3
echo    '<array>' >&3
echo        '<dict>' >&3
echo            '<key>AccountPath</key>' >&3
echo            '<string>~/Library/Mail/V2/Mailboxes</string>' >&3
echo            '<key>AccountType</key>' >&3
echo            '<string>LocalAccount</string>' >&3
echo            '<key>ArchiveMailboxName</key>' >&3
echo            '<string>Archive</string>' >&3
echo            '<key>ConfigureDynamically</key>' >&3
echo            '<false/>' >&3
echo            '<key>DraftsMailboxName</key>' >&3
echo            '<string>Drafts</string>' >&3
echo            '<key>JunkMailboxName</key>' >&3
echo            '<string>Junk</string>' >&3
echo            '<key>NotesMailboxName</key>' >&3
echo            '<string>Notes</string>' >&3
echo            '<key>SentMessagesMailboxName</key>' >&3
echo            '<string>Sent Messages</string>' >&3
echo            '<key>TrashMailboxName</key>' >&3
echo            '<string>Deleted Messages</string>' >&3
echo            '<key>uniqueId</key>' >&3
echo            '<string>LocalAccountId</string>' >&3
echo        '</dict>' >&3
echo        '<dict>' >&3
echo            '<key>AccountName</key>' >&3
echo            "<string>Company eMail</string>" >&3
echo            '<key>AccountPath</key>' >&3
echo            "<string>~/Library/Mail/V2/IMAP-${LoggedInUser}@imap.yourcompany.com</string>" >&3 # Specifies IMAP Account for current user
echo            '<key>AccountType</key>' >&3
echo            '<string>IMAPAccount</string>' >&3
echo            '<key>ArchiveMailboxName</key>' >&3
echo            '<string>Archive</string>' >&3
echo            '<key>ConfigureDynamically</key>' >&3
echo            '<false/>' >&3
echo            '<key>DateOfLastSync</key>' >&3
echo            '<date>2014-01-01T00:00:00Z</date>' >&3
echo            '<key>DaysBetweenSyncs</key>' >&3
echo            '<integer>5</integer>' >&3
echo            '<key>DraftsMailboxName</key>' >&3
echo            '<string>Drafts</string>' >&3
echo            '<key>EmailAddresses</key>' >&3
echo            '<array>' >&3
echo                "<string>${LoggedInUser}@yourcompany.com</string>" >&3 # Current users email address
echo            '</array>' >&3
echo            '<key>FullUserName</key>' >&3
echo            "<string>${FullUserName}</string>" >&3
echo            '<key>Hostname</key>' >&3
echo            '<string>imap.yourcompany.com</string>' >&3 # IMAP Server needs to be specified here
echo            '<key>JunkMailboxName</key>' >&3
echo            '<string>Junk</string>' >&3
echo            '<key>NotesMailboxName</key>' >&3
echo            '<string>Notes</string>' >&3
echo            '<key>PortNumber</key>' >&3
echo            '<integer>143</integer>' >&3
echo            '<key>SMTPIdentifier</key>' >&3
echo            "<string>smtp.yourcompany.com:${LoggedInUser}</string>" >&3 # Sets SMTP Login credentials
echo            '<key>SSLEnabled</key>' >&3
echo            '<string>YES</string>' >&3
echo            '<key>SentMessagesMailboxName</key>' >&3
echo            '<string>Sent Messages</string>' >&3
echo            '<key>StoreDraftsOnServer</key>' >&3
echo            '<string>YES</string>' >&3
echo            '<key>StoreSentMessagesOnServer</key>' >&3
echo            '<string>YES</string>' >&3
echo            '<key>ToDosMailboxName</key>' >&3
echo            '<string>Apple Mail To Do</string>' >&3
echo            '<key>TrashMailboxName</key>' >&3
echo            '<string>Deleted Messages</string>' >&3
echo            '<key>Username</key>' >&3
echo            "<string>${LoggedInUser}</string>" >&3
echo        '</dict>' >&3
echo    '</array>' >&3
echo    '<key>OutboxMailboxPath</key>' >&3
echo    '<string>~/Library/Mail/V2/Mailboxes/Outbox.mbox</string>' >&3
echo '</dict>' >&3
echo '</plist>' >&3


# Copying Accounts.plist into Mail V2 Folder
logger "Copying Accounts.plist into MailData Folder"
cp /tmp/Accounts.plist ${MailData}


# Setting correct permissions for Account.plist
logger "Setting owner of Accounts.plist to ${LoggedInUser}"
chown -R ${LoggedInUser} ${Mail}


# Removing Accounts.plist in Temporary Folder
logger "Removing temp Account.plist in /tmp"
rm -Rf /tmp/Accounts.plist

exit 0