WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADSI LDAP CDO
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Create Exchange Distribution List Using CDO


Question:

I have tried several methods to create a mailbox for a group after it is created. My code looks like this.
path1="LDAP://Domain Controller/"
path2=",OU=DL-PERSONAL,OU=DISTRIBUTION LISTS,DC=Domain,DC=com"
sAdsiPath2 = "LDAP://Domain Controller/OU=DL-PERSONAL,OU=DISTRIBUTION LISTS,DC=Domain,DC=com" 

dom=objectaccess(sAdsiPath2,@FALSE)
DL=strcat("cn=", DLNAME)
sObjectpath3=dom.create( "GROUP",dl )
TimeDelay(1)

sObjectpath3.Put("sAMAccountName", DLNAME)
sObjectpath3.setinfo

sObjectpath3.Put("displayName",DLNAME)
sObjectpath3.Put( "grouptype","8" )
sObjectpath3.setinfo

sObjectPath2= strcat(path1,dl,path2)

TimeDelay(1) 
homeMDB="CN=Mailbox Store (MAILSERVER),CN=First Storage Group,CN=InformationStore,CN=MAILSERVER,CN=Servers,CN=SITE2,CN=Administrative Groups,CN=FIRM1,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=Domain,DC=com" 

objuser=objectopen(sObjectPath2)
objMailbox=ObjectOpen("CDOEXM.MailboxStoreDB")
objMailbox=objuser
ObjMailbox.CreateMailbox(homemdb) 
I get an error 1258: OLE Unknown Name error at the line (ObjMailbox.CreateMailbox(homemdb))

I originally tried sObjectpath3 instead of opening sObjectPath2 and received the same error. I have tried several other methods from the search page but they all return the same error.

Thanks in advance to for any help.

Answer:

Just a quick stab at it.
;This is completely untested.

;Path to ou
strPath = "LDAP://Domain Controller/OU=DL-PERSONAL,OU=DISTRIBUTION LISTS,DC=Domain,DC=com" 
strGroupName = strCat("cn=",DLName) ; in your code but not identified
strSamAcctName = DLName ; in your code but not identified
IGrouptype = 8 ;from your code

iAdCont = ObjectGet(strPath)
iAdGroup = iAdCont.Create("group", strGroupName)
iAdGroup.Put ("sAMAccountName", strSamAccountName)
iAdGroup.Put ("groupType", IGroupType)

iMailRecip = iAdGroup
iMailRecip.MailEnable

iAdGroup.SetInfo

iAdCont = 0
iAdGroup = 0
iMailRecip = 0 

User Reply:

Yeah! I ran this on my exchange server and it made a mail enabled group.
Article ID:   W16575
File Created: 2005:02:18:12:21:30
Last Updated: 2005:02:18:12:21:30