Sorry for the re-post, but I have refined the script so it only does 2 dscl
lookups instead of all of them. There is also an error check that will bail
from the script if the username is not legit, or if the DC is not reachable.
Once again...watch for the line wraps and all...
-Mike
__________8<____________
--set Exchange to offline
tell application "Microsoft Entourage"
set working offline to true
end tell
--create a temp file to write the user record to in order to avoid opening a
lot of dscl connections
set tempFile to do shell script "/usr/bin/mktemp
/tmp/ConfigureEntourage_XXXXXXXX"
--prompt for the network ID
set userName to ""
repeat while userName = ""
set theResponse to (display dialog ¬
"Please enter your network ID (ex. smithj):" default answer ""
giving up after 10)
set userName to text returned of theResponse
if gave up of theResponse then
return
end if
end repeat
--verify that the userName supplied above is valid and bail either if it
isn't or there's a problem connecting to the server
try
do shell script "/usr/bin/dscl localhost read /Active\\
Directory/company.com/Users/" & userName & " >" & tempFile
on error
display dialog "Unable to verify that \"" & userName & "\" is a valid
user. Please check the network ID and try again. Please go to the TOOLS
menu, RUN SCHEDULE and SETUP" buttons "OK" default button "OK" giving up
after 10
--make sure the user record is deleted in case something went wrong
do shell script "/bin/rm -f " & tempFile
return
end try
--get the necessary information from the user record
try
set recordLength to do shell script "/usr/bin/wc -l " & tempFile & "|
/usr/bin/awk '{print $1}'"
set lastName to do shell script "awk '/LastName:/ {print $2}' " &
tempFile
set firstName to do shell script "awk '/FirstName:/{print $2}' " &
tempFile
set mailNickname to do shell script "awk '/mailNickname:/{print $2}' " &
tempFile
set displayName to do shell script "awk '/displayName:/{print $2}' " &
tempFile
set emailAddress to do shell script "awk '/mail:/{print $2}' " &
tempFile
set domainName to "lmsd.org"
set ldapPort to "3268"
set homeMTA to do shell script "dscl localhost -read /Active\\
Directory/company.com/Users/" & userName & " " & "homeMTA | sed 's/homeMTA:
//' "
copy "" to MTAserver
copy (offset of "CN=Microsoft MTA,CN=" in homeMTA) to startChunk
if startChunk is not 0 then
copy (characters (startChunk + 20) through (count of characters of
homeMTA) of homeMTA) as text to chunk
copy (offset of "," in chunk) to endChunk
copy (characters 1 through (endChunk - 1) of chunk) as text to
MTAserver
end if
copy MTAserver & "." & domainName to exchangeServer
set fullName to firstName & " " & lastName
--get the other necessary variables like mailNickname, then delete the
user record:
do shell script "/bin/rm -f " & tempFile
on error errMsg
display dialog errMsg buttons "OK" default button "OK" giving up after
10
--make sure the user record is deleted in case something went wrong
do shell script "/bin/rm -f " & tempFile
end try
--the rest of the script goes here
tell application "Microsoft Entourage"
if exists Exchange account lastName then
delete Exchange account lastName
end if
make new Exchange account with properties {name:lastName, Exchange
server:exchangeServer, Exchange ID:mailNickname, domain:domainName, free
busy server:exchangeServer & "/public/", full name:displayName, email
address:emailAddress, LDAP server:"dc.company.com", LDAP port:ldapPort,
search base:"", maximum entries:100, partially retrieve messages:true,
partially retrieve messages size:50000}
set enabled of schedule "setup" to false
delete schedule "setup"
end tell
display dialog "You will now receive two warnings that a script (this
script) is trying to access your Entourage address book. Please allow access
to the address book by clicking the OK button on each warning. Please enter
your network password when prompted. It will take a few minutes for your
email to synchronize with the server. Please be patient. Thank you."
buttons {"OK"} default button "OK"
tell application "Microsoft Entourage"
activate
set name of me contact to fullName
set address of me contact to emailAddress
set working offline to false
end tell
On 6/15/06 3:22 PM, "Perbix, Michael" <[EMAIL PROTECTED]> wrote:
> BTW, for all interested, here is the script I came up with, which takes a
> most of what Joseph Swenson did, and added a chunk from an example by Greg
> Neagle on the Macenterprise list.
>
_______________________________________________
Michael Perbix
Lower Merion School District
Telecommunications Specialist
(610) 645-1964 - Work
(610) 896-2019 - Fax
--
To unsubscribe:
<mailto:[EMAIL PROTECTED]>
archives:
<http://www.mail-archive.com/entourage-talk%40lists.letterrip.com/>
old-archive:
<http://www.mail-archive.com/entourage-talk%40lists.boingo.com/>