Page 1 of 2 12>
Topic Options
#85963 - 2002-06-06 01:22 PM Deleting Exchange Mailboxes
Dean R Offline
Starting to like KiXtart

Registered: 2002-03-15
Posts: 115
Loc: Ireland, but Im an Aussie
Is it possible to delete a mailbox from an exchange 5.5 server using ADSI? or any other method for that matter. I can find no command line tool that will allow me to do it.
_________________________
-------------------------------- When you can take this stone from my hand Gwasshoppa you are read... *yoink* Gwasshoppa? Gwasshoppa? Where did you go? ---------------------------------

Top
#85964 - 2002-06-06 02:21 PM Re: Deleting Exchange Mailboxes
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Dean,

Doing a quick search, we find..

Deleting a mailbox..
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wss/wss/_cdo_deleting_a_mailbox.asp

Administrative Tasks..
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wss/wss/_cdo_recipient_management_tasks.asp

These should be portable to Kix...

Uh.. Wait a sec, these are for Exchange 2000.

OK.. 5.5.

Deleting a mailbox..
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ds2x/hh/ds2x/exds_ds2exchgd_40c4.asp

Adminstrative Tasks..
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ds2x/hh/ds2x/exds_ds2exchgd_5pgl.asp

HTH,

- Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#85965 - 2002-06-06 02:21 PM Re: Deleting Exchange Mailboxes
Breaker Offline
Hey THIS is FUN
*****

Registered: 2001-06-15
Posts: 268
Loc: Yorkshire, England
Dean,

You could look at this page for an example of how to do this.

And meanwhile - and I know this is well off-topic - are there any Exchange gurus, as well as avid Kixters around here? I have a problem with my Exchange org, connecting to mailboxes across domains. I won't post the details here, but if anyone thinks they might be able to help, or would just like to know the extent of my troubles so they can laugh at me, drop me an email or a private message.

Sorry about that, Dean, not trying to hijack your topic, but you gave me an opportunity to ask my question without actually asking it - cunning, eh?

I've not tried to use ADSI to talk to Exchange, but it should work fine in 5.5 and 2000. I believe Howard Bullock and Chris S have done some work in this area as well.
_________________________
================================================
Breaker


Top
#85966 - 2002-06-06 02:42 PM Re: Deleting Exchange Mailboxes
Dean R Offline
Starting to like KiXtart

Registered: 2002-03-15
Posts: 115
Loc: Ireland, but Im an Aussie
Yes, but I am having trouble writing that into Kix

This is the script, it comes back with an error when it hits "organizationalPerson"
code:
$Object = GetObject ("LDAP://LIMSRVEMAIL1")
$Object.delete "organizationalPerson","cn=tmctest"
$Object.SetInfo
Sleep 5

_________________________
-------------------------------- When you can take this stone from my hand Gwasshoppa you are read... *yoink* Gwasshoppa? Gwasshoppa? Where did you go? ---------------------------------

Top
#85967 - 2002-06-06 03:00 PM Re: Deleting Exchange Mailboxes
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Dean,

I don't think you've properly defined the container path yet. As a test, you can query the mailbox info for your test account. If you can read the info, then, with the appropriate rights, you should be able to delete it.

Your container path should at least include the following:

quote:
'---------------------------------------------------------------
' Build Recipient container's adsPath:
' LDAP://myserver/CN=Recipients, OU=Site, O=Org
'---------------------------------------------------------------
ADsPath = "LDAP://" + yourserver
ADsPath = ADsPath + "/cn=Recipients,OU="
ADsPath = ADsPath + yourSite
ADsPath = ADsPath + ",O="
ADsPath = ADsPath + yourOrg

After you build your container path, then you can grab the mailbox you want to manipulate:

quote:

Set objCont = GetObject(ADsPath)

'---Create a new MailBox---
Set mailBox = objCont.Create("organizationalPerson", "cn=" & strAlias)

The above sample is a VB example to create an account, changing the "create" to "delete" should (I hope) get the job done. Unfortunately, I can't test this with you as I don't have admin rights on our Exchange server (yet).

edit: 'strAlias' is defined earlier in the script as 'username' which in their example is the UID (or Alias of the Exchange account) and the RDN (NT account associated to the mailbox).

[ 06 June 2002, 15:12: Message edited by: Chris S. ]

Top
#85968 - 2002-06-06 03:11 PM Re: Deleting Exchange Mailboxes
Dean R Offline
Starting to like KiXtart

Registered: 2002-03-15
Posts: 115
Loc: Ireland, but Im an Aussie
No, still doesnt work, it gives me a script error still.
It says

code:
OrganizationalPerson Script Error : Unknown Command!  

_________________________
-------------------------------- When you can take this stone from my hand Gwasshoppa you are read... *yoink* Gwasshoppa? Gwasshoppa? Where did you go? ---------------------------------

Top
#85969 - 2002-06-06 03:20 PM Re: Deleting Exchange Mailboxes
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Can you 'object.get' any of the properties ("cn", "uid", "mail", etc.)?

The examples don't say you have to go though the Assoc-NT-Account route, but if you can see the properties but not delete still then maybe...

[ 06 June 2002, 15:20: Message edited by: Chris S. ]

Top
#85970 - 2002-06-06 03:21 PM Re: Deleting Exchange Mailboxes
Dean R Offline
Starting to like KiXtart

Registered: 2002-03-15
Posts: 115
Loc: Ireland, but Im an Aussie
Yes, I can see all those.
.get no problem
.delete wont work
yes I have admin rights to the server
_________________________
-------------------------------- When you can take this stone from my hand Gwasshoppa you are read... *yoink* Gwasshoppa? Gwasshoppa? Where did you go? ---------------------------------

Top
#85971 - 2002-06-06 03:24 PM Re: Deleting Exchange Mailboxes
Breaker Offline
Hey THIS is FUN
*****

Registered: 2001-06-15
Posts: 268
Loc: Yorkshire, England
Dean,

Try this:

code:
$objCont = GetObject("LDAP://exchangeserver/cn=recipients,ou=sitename,o=org")
if $objcont
? "Bound to LDAP server, Recipients container."
$objcont.delete("organizationalPerson","cn=test")
? "Deleting Test mailbox"
$objcont.setinfo
? "Committing changes to container."
$objcont = 0
goto end
endif

? "Could not bind to LDAP server."

:end
Exit

It works for me on my Exchange 5.5 SP4 box. Hope this helps!
_________________________
================================================
Breaker


Top
#85972 - 2002-06-06 03:29 PM Re: Deleting Exchange Mailboxes
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
I wonder if it has anything to do with parentheses. I haven't had a lot of luck with Com stuff that doesn't use a ( ) in the object command.
Top
#85973 - 2002-06-06 03:33 PM Re: Deleting Exchange Mailboxes
Dean R Offline
Starting to like KiXtart

Registered: 2002-03-15
Posts: 115
Loc: Ireland, but Im an Aussie
5 stars to breaker,
well done me boy.
I now love ADSI and COM objects.

Will try and write a UDF for this one.
[Big Grin] [Big Grin] [Big Grin] [Big Grin] [Roll Eyes] [Smile] [Big Grin]
_________________________
-------------------------------- When you can take this stone from my hand Gwasshoppa you are read... *yoink* Gwasshoppa? Gwasshoppa? Where did you go? ---------------------------------

Top
#85974 - 2002-06-06 03:36 PM Re: Deleting Exchange Mailboxes
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
yip - nice one - five from me as well.
Top
#85975 - 2002-06-06 03:38 PM Re: Deleting Exchange Mailboxes
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Well, I'm glad Breaker could help. I quess I didn't add much to the process. [Wink] JK.

I wonder if the .delete is looking for the UID or the RDN? This could make a difference in your script if they don't match.

Top
#85976 - 2002-06-06 04:05 PM Re: Deleting Exchange Mailboxes
Breaker Offline
Hey THIS is FUN
*****

Registered: 2001-06-15
Posts: 268
Loc: Yorkshire, England
Guys,

For future reference, this link: Click me! should be useful. Exchange 5.5 SDK docs.

Looking forward to the complete set of Exchange admin UDFs, Dean!

[sly...] don't suppose anyone saw my desperate plea for help at the top. Any Exchange genii watching? [Wink]
_________________________
================================================
Breaker


Top
#85977 - 2002-06-06 06:16 PM Re: Deleting Exchange Mailboxes
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
I just found something that should be looked at. It seems that deleting a mailbox with this method will orphan the store resources. So...besides not only leaving the info hogging up the server's disk space, the next person to get that mailbox name will find their mailbox already populated with someone else's mail!

The M$ method uses DAPI to delete the directory object AND the store.

Reference:

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q284199

Top
#85978 - 2002-06-07 09:24 AM Re: Deleting Exchange Mailboxes
Breaker Offline
Hey THIS is FUN
*****

Registered: 2001-06-15
Posts: 268
Loc: Yorkshire, England
Errr... that looks a bit hardcore to me. Kind of best left to guys who spend all day sitting in darkened rooms... does anyone know if the example at Chris' link would be KiXable?

This link shows an alternate method of deleting multiple mailboxes and other Exchange objects, but it's not really open to scripting unless you want to build the csv file via a script (?). I think I may be stuck trying to go any further - might have to wait for a flash of brilliance from somebody... Chris, Shawn, Millennium Man (Rad!) ??

[time passes slowly when no one has come to work today because of the England game...]

I was just thinking, your best bet if you need to script this operation might be to shell out to the Exchange Admin program, using its /i and /e switches to perform the directory import/export process, and simply editing the csv file in between. I'll try and cobble something together that would do this...

[ 07 June 2002, 10:01: Message edited by: Breaker ]
_________________________
================================================
Breaker


Top
#85979 - 2002-06-07 09:48 AM Re: Deleting Exchange Mailboxes
Dean R Offline
Starting to like KiXtart

Registered: 2002-03-15
Posts: 115
Loc: Ireland, but Im an Aussie
Damn!! (crumples up attempt at UDF)
And I was so happy about that too.
Another alternate method is to install the Admin Service on the Backoffice 4.5 resource kit, and then postie an email to the administration account.
The Admin service places a mailbox on the server that reacts to emails and creates and/or deletes mailboxes.
Havent tested it yet as the f$#%in thing wont install for me.
[Mad]
_________________________
-------------------------------- When you can take this stone from my hand Gwasshoppa you are read... *yoink* Gwasshoppa? Gwasshoppa? Where did you go? ---------------------------------

Top
#85980 - 2002-06-12 10:57 AM Re: Deleting Exchange Mailboxes
Dean R Offline
Starting to like KiXtart

Registered: 2002-03-15
Posts: 115
Loc: Ireland, but Im an Aussie
BUMP

Did you see any reference to problems creating a mailbox using ADSI in 5.5?
I couldnt find any, so the whole UDF thingymibob might still be worth writing, but in reverse, create instead of delete.
Will look into it.
God I want Exchange 2000, damn micro$oft and their Active Directory.
Actually I should say, damn the transmitter manufacturers and their inability to update their software to work with it. [Big Grin]

P.S- Anyone here use the Admin Agent for Exchange 5.5?, still cant get the damn thing working.

[ 12 June 2002, 10:59: Message edited by: Dean R ]
_________________________
-------------------------------- When you can take this stone from my hand Gwasshoppa you are read... *yoink* Gwasshoppa? Gwasshoppa? Where did you go? ---------------------------------

Top
#85981 - 2002-06-12 01:02 PM Re: Deleting Exchange Mailboxes
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
No problems creating mailboxes at all. I think KiX would be very good at it, in fact.
Top
#85982 - 2002-06-12 10:28 PM Re: Deleting Exchange Mailboxes
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Does this ADSI stuff work if you don't have the LDAP setup on your network?

I have an interesting problem:

Some users NEVER log on to our network but get email via pop3, so it is very difficult to figure out what accounts are active or not. (I don't make the policy!!!) This is compounded by the fact that McAfee GroupShield runs on our exchange server and logs in every couple of weeks when we run an "on-demand" scan of all our mailboxes, so it shows the last logon as being the McAfee and not the user... so.. does anyone have a solution for finding out which users have been active within the last 60 days, even though they do not always log in through our domain controllers?

Brian

Top
Page 1 of 2 12>


Moderator:  Shawn, ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 145 anonymous users online.
Newest Members
Jodey, Hiker, GTRoberts, KatieQuinn, Brennnnn
17684 Registered Users

Generated in 0.043 seconds in which 0.012 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