Question on the Exchange setup that you have. Do you have all of the users in a single container or do you have multiple containers? If in multiple containers, is there a way you can tell which one they are in? Because if you knew which container they were in you could use the exchange admin program and do a command line export of the GAL and parse through it line by line searching for a matching First Name and last name, then when you find it, go to the SMTP portion of the line and extract it to get the addy.

I have included sample code below. The only assumption is that you have the Exchange admin program loaded on the machine that this is being run on

code:

break on

$fname = "Paul" ;The user's first name
$Lname = "Berquam" ;
$exch = "Y" ;

? "Searching for $fname $lname" ?

;options.txt is a file with the following
;
;[Export]
;Subcontainers=Yes
;Basepoint=/o=<ORGNAME>/ou=<SITENAME>/cn=<CONTAINERNAME>
;
;End of options.txt
;note: The container is optional, if you don't enter it it should go to the GAL


if $exch = "Y"
$exchadminpath = readvalue("HKEY_LOCAL_MACHINE\Software\Microsoft\Exchange\Setup","AdminDest")

$exchfile = "c:\temp\testexch.csv"
$options = "c:\options.txt"
$DSNAME = "YOUREXCHANGESERVERNAME" ;Directory server name

if exist($exchfile)
del "$exchfile"
endif

$nul = open (7,$exchfile,1)
$nul = close(7)

shell "$exchadminpath\admin.exe /e $exchfile /d $DSNAME /o $options" ;for export
;Note that you can include a /n switch so that it doesn't display the gui export screen. ;I kept it so that I could be sure that it was it was doing something
$found = 0
$found2 = 0
$count = 0
$countfirst = 0
$countlast = 0

$line = "none"
$nul = open(7,$exchfile,2)
? "Searching..."
while $line <> ""
$line = readline(7) "."
$count = $count + 1
$found = instr($line,$fname) ; ? "$fname $line"
if $found <> 0
$countfirst = $countfirst + 1
$found2 = instr($line,$lname)
if $found2 <> 0
$mailstart = instr($line,"SMTP:")
$linelen = len($line)
$line2 = substr($line,$mailstart,$linelen - $mailstart)
$mailend = instr($line2,"%")
$mailaddy = substr($line2,6,$mailend-6)
$countlast = $countlast + 1
endif
endif
loop
$nul = close(7)

? "$count records searched"
if $countlast > 0
? "$fname $lname found"
? "Mail address is $mailaddy"
else
? "$fname $lname not found"
endif
endif

? ? "$countfirst name(s) matching $fname"
? "$countlast name(s) matching $lname"
? "End"
get $c



------------------
"He was a good little monkey and always very curious..."

[This message has been edited by Paul_Berquam (edited 06 December 2000).]

[This message has been edited by Paul_Berquam (edited 06 December 2000).]

_________________________
He was a good little monkey and always very curious...