Page 1 of 2 12>
Topic Options
#52565 - 2000-12-05 10:16 PM Pull SMTP email address from an exchange server
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Hey guys, i was wondering if any one knew how to poll an exchange server with a user ID and get the user's primary smtp email address? LDAP maby?

Bryce

Top
#52566 - 2000-12-05 10:32 PM Re: Pull SMTP email address from an exchange server
Paul_Berquam Offline
Hey THIS is FUN

Registered: 2000-08-02
Posts: 310
Loc: Sacramento, CA USA
Sorry Bryce, it may not be the best solution. Depends on where your server is located. Even if you poll it, you may spend the next month recounting the poll.

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

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

Top
#52567 - 2000-12-05 10:35 PM Re: Pull SMTP email address from an exchange server
Paul_Berquam Offline
Hey THIS is FUN

Registered: 2000-08-02
Posts: 310
Loc: Sacramento, CA USA
Seriously though. I was looking for the same kind of thing. Not for the Email addy since we have standardized them. I was interested in doing something on the intranet here. Anyway, found some info here

I haven't had time to look into it, hopefully someone else has some insight.

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

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

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

Top
#52568 - 2000-12-06 01:24 PM Re: Pull SMTP email address from an exchange server
Anonymous
Unregistered


Hey that reminded of something I was workign on a while ago....ADSI!!! Or Active Directory Service Interface. With ADSI you can create/delete users and user info, as well as create/delete/update mailbox information. The problem is how to get kixtart communicating with ADSI. But ADSI supports Visual Basic Scripting, so it shouldn't be impossible. I would be worth a look, because it is really a powerfull toy. Read more about it here: http://www.microsoft.com/windows2000/library/howitworks/activedirectory/adsilinks.asp

If you find out how to use it with kixtart, please post some examples

Top
#52569 - 2000-12-06 03:01 PM Re: Pull SMTP email address from an exchange server
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Bryce:

Like David said - we could probably pull something together with OLE/ADSI.

But you know the score with ADSI - it comes standard with Win2K and is "installable" on WinNT.

Is this meant to be part of an NT logon script - or as a standalone admin tool ?

I's anyone aware of any commandline utilities for pulling this info ?

Shawn.

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

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
It is a needed part of an idea that I had, well not a key part but more of a user comfort part.

The original idea that I had was to create a script that ran as a service on NT server. This script would monitor the disk usage of the user folders. When a quota was reached the script would remove the write rights for that user on their folder. The email part would be used for notifying the user that they have exceeded their disk quota.

I don't know if this would be a doable idea or not, but it was a thought Mainly how to collect the disk usage data. I toyed around with DIRUSE but i was using it on a network resource and it was on the slow side......

running it on the local server, got a little bit faster results......

Bryce

Bryce


Top
#52571 - 2000-12-06 05:24 PM Re: Pull SMTP email address from an exchange server
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Super idea !

A sort of "roll your own" Quota Manager" !

I could use something like that. I've got some user communities that definitely push the bounds of "reasonable" disk usage.

I could see this service of yours initializing itself from an INI file - sort of a "list of shares" thing - and each share would have a quota and an email address attached to it.

Then all you'd need to do is use one of those automatic mailer thingy programs (BLAT?) - and wow ! - great idea !

Shawn.


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

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Hmmm here is a list of my 3 biggest users.

Size (mb) Files Directory
! 1181.19 7677 SUB-TOTAL: D:\USERS\brycel
! 1251.64 3295 SUB-TOTAL: D:\USERS\feil
! 2922.32 6212 SUB-TOTAL: D:\USERS\leachb


Bryce

Top
#52573 - 2000-12-06 06:17 PM Re: Pull SMTP email address from an exchange server
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
here is some interesting information about diruse and my user folders.

Size (mb) Files Directory
25392.05 132183 TOTAL

TimeThis : Command Line : diruse /m /* d:\users
TimeThis : Start Time : Wed Dec 06 11:05:33 2000
TimeThis : End Time : Wed Dec 06 11:07:12 2000
TimeThis : Elapsed Time : 00:01:38.859

Bryce

Top
#52574 - 2000-12-06 07:46 PM Re: Pull SMTP email address from an exchange server
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Yikes !

How many user shares do you have ?

Would be interesting if you could write a little test script that read a text file containing the paths of all your user folders - do a diruse on each one and get the overall elapsed time for that !

Shawn.

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

Top
#52575 - 2000-12-06 09:02 PM Re: Pull SMTP email address from an exchange server
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
I have 338 user shares

using this code, to build a database/ini file

code:

break on cls

$path = "d:\users"
$tempfile = "%temp%\temp.dat"
$database = "d:\diruse.ini"

if exist($database) = 0
$nul = open(1,$database,5)
$nul = close(1)
endif

? "Building $Database"
$return = dir("$path\*.*")
while @error = 0
select
case $return = "." or $return = ".."
;ignore
case (getfileattr("$path\$return") & 16) = 16
; $return will equal a dir or a file,
; depending on how $dirfileflag was set
shell '%comspec% /c diruse /m "$path\$return" | find /i " total:" > $tempfile'
$nul = open(1,$tempfile,2) $data = readline(1) $nul = close(1)
$foldersize = ltrim(substr($data,1,13))
$nul = writeprofilestring("$database","DIRUSE","$return","$foldersize") "."
endselect
$return = dir()
loop


It took a total of 00:01:50.765 to run.

Bryce

Top
#52576 - 2000-12-06 09:13 PM Re: Pull SMTP email address from an exchange server
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
That ran relatively fast - all things considered - what's your next step ?

Shawn.

Top
#52577 - 2000-12-06 09:43 PM Re: Pull SMTP email address from an exchange server
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Don't know. I have been thinking about what would be the best way to run this.

I am thinking about breaking it up in to 2 time groups.

Group 1 is ran once every 10 min, but this scan will only check the users that are close to and or over the limit (only using the information that is supplied from the database, and not doing a full diruse scan).

Group 2 would run once every 2 hours and it would run doing a full diruse scan

Thinking about using a 3 strikes your out rule too. You will have to be over your limit for 3 scans in a row before write access is removed. This is where I would like to use email as a warning tool.

I would like to have some way of notifying the user that their user folder is over it's size limit, and i can only use their USERID to do this. If all my users were NT i would just do a "net send" message, but.... this is not the case.

Bryce

Top
#52578 - 2000-12-06 10:15 PM Re: Pull SMTP email address from an exchange server
Paul_Berquam Offline
Hey THIS is FUN

Registered: 2000-08-02
Posts: 310
Loc: Sacramento, CA USA
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...

Top
#52579 - 2000-12-06 10:19 PM Re: Pull SMTP email address from an exchange server
Paul_Berquam Offline
Hey THIS is FUN

Registered: 2000-08-02
Posts: 310
Loc: Sacramento, CA USA
Instead of running this each time you could also do a check date and if it's not current, it reexports the data for the most current list. Then parse it for each glutton user.

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

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

Top
#52580 - 2000-12-06 10:33 PM Re: Pull SMTP email address from an exchange server
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Thanks!

I will take at look at this. All of my users are in a single container.

Bryce

Top
#52581 - 2000-12-06 10:39 PM Re: Pull SMTP email address from an exchange server
Paul_Berquam Offline
Hey THIS is FUN

Registered: 2000-08-02
Posts: 310
Loc: Sacramento, CA USA
In that case, in the options file, leave the \cn=... portion out, or just set it to the single container name.

Tested it here with a few names and it seems to work. Of course performance will depend on how big the GAL is. In fact my script for screating the user accounts uses the import mode of admin.exe to create the mailboxes. One of these days I'll get around to cleaning it up and posting it.

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

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

Top
#52582 - 2000-12-06 10:52 PM Re: Pull SMTP email address from an exchange server
Paul_Berquam Offline
Hey THIS is FUN

Registered: 2000-08-02
Posts: 310
Loc: Sacramento, CA USA
I just updated the code. I found a record that I couldn't find for some reason. I changed it so that it had a separate counter for the fname and lname instances.

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

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

Top
#52583 - 2000-12-06 11:16 PM Re: Pull SMTP email address from an exchange server
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Paul,

Thanks for the code! I learned something new today! Using your code I am writing a script that will populate my database with the windows ID/smtp:address.

Thanks a lot!

Bryce

PS: this BBS is by far one of the best around!

Top
#52584 - 2000-12-06 11:19 PM Re: Pull SMTP email address from an exchange server
Paul_Berquam Offline
Hey THIS is FUN

Registered: 2000-08-02
Posts: 310
Loc: Sacramento, CA USA
I would definitely have ot agree with you there.

If I may ask, what's the db for? Are you using it so that you can use the addy as a UPN for 2k users or something?

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

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

Top
Page 1 of 2 12>


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

Who's Online
1 registered (Allen) and 363 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

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

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