Page 2 of 2 <12
Topic Options
#52585 - 2000-12-06 11:26 PM Re: Pull SMTP email address from an exchange server
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
I need the @userid/smtp address for a quota script that I will be running on my user folders.

Since the user folders are configed to use @userid, I will simply use that to identify the folders owner.

As it stands now, to take full advantage of my quota script, you will need to keep the database updated. You would do this by periodically running the exchange script that I am working on, it will update the database that the main quota script uses.

Bryce

Top
#52586 - 2000-12-08 05:00 PM Re: Pull SMTP email address from an exchange server
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Thanks to Paul! I came up with the following.

code:

break on cls
;----------------------------------------------------------------------------------------------
; This script will pull the userid and smtp address from an exchange server and create a ini
; databse file.
;
; This script must be ran on the exchange server, under a useraccount that has exchange admin
; rights.
;
; IF an Useraccount is found that has more than 1 SMTP address, you will be prompted to choose
; what SMTP address to use.
;----------------------------------------------------------------------------------------------

$orgname = "<orgname>" ;your mail orginization name
$sitename = "<sitename>" ;your mail site name
$ExchangeServer = "@wksta" ;your mail server name
$domain = "@domain" ;your domain name


$database = "\\server\c$\email.ini" ;the name of the ini databse file
$DBName = "EMAIL"


$cr = chr(13)+chr(10)
$options = "%temp%\export.tmp"
$dumpfile = "%temp%\dumpfile.tmp"
$tempfile = "%temp%\temp.tmp"
;----------------------------------------------------------------------------------------------

$options_txt = '[Export]'+$cr+'Subcontainers=Yes'+$cr+'Basepoint=/o=$orgname/ou=$sitename'
$exchadminpath = readvalue("HKEY_LOCAL_MACHINE\Software\Microsoft\Exchange\Setup","AdminDest")

if exist($options) = 1 del "$options" endif
if exist($dumpfile) = 1 del "$dumpfile" endif

$nul = open(1,$options,5) $nul = writeline(1,$options_txt) $nul = close(1)

? "Dumping GAL from $ExchangeServer..."
shell '$exchadminpath\admin.exe /e $tempfile /d $Exchangeserver /o $options'
? "Filtering GAL for SMTP addresses only"
shell '%comspec% /c type "$tempfile" | find /i "SMTP:" > "$dumpfile"'

del "$tempfile" del "$options"

$nul = open(1,$dumpfile,2)
$line = readline(1)

? "Initializing the database..."
$nul = writeprofilestring($database,$dbname,"","")
do
$line = substr($line,instr($line,$domain)+len($domain)+1,len($line))
$userid = substr($line,1,instr($line,",")-1)
$line = substr($line,instr($line,"SMTP:")+ len("SMTP:"),len($line))
$smtp = substr($line,1,instr($line,"%%")-1)

select
case $userid <> ""
select
case readprofilestring($database,$DBName,$userid) <> ""
? "$userid has multi SMTP address: please pick 1 to use"
? "(A)$smtp (B)" readprofilestring($database,$DBName,$userid)
:AB
get $AB
select
case $ab = "A"
$nul = writeprofilestring($database,$DBNAME,$userid,$smtp)
case $ab = "B"
; do nothing
case 1
beep goto AB
endselect
?
case 1
$nul = writeprofilestring($database,$dbname,$userid,$smtp)
endselect
case 1
? "Dead account---"
? $smtp ?
endselect
$line = readline(1)
until @error <> 0

$nul = close(1)
del $dumpfile



Top
Page 2 of 2 <12


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 611 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.048 seconds in which 0.022 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org