newbie trying to create mailboxes

I am writing a Active directory program, im stuck on the bit where I
add mailboxes to accounts. I got some code of the microsoft website
that creates a mailbox for a specified user, I need to create a mailbox
for all users in a group called TaxGroup in the users container.Could I
get some help modifying it to add the a Group.

Dim oIADSUser
Dim oMailbox

Set oIADS = GetObject("LDAP://RootDSE")
strDefaultNC = oIADS.Get("defaultnamingcontext")
'MsgBox FindAnyMDB("CN=Configuration," & strDefaultNC)

'TODO: Use the newly created domain user account to replace the
"UserName".
Set oIADSUser = GetObject("LDAP://CN=UserName,CN=Users," &
strDefaultNC)

If oIADSUser Is Nothing then
	MsgBox "The oIADSUser is Nothing."
Else
	MsgBox "The oIADSUser is created successfully."
End If

Set oMailBox = oIADSUser
oMailbox.CreateMailbox FindAnyMDB("CN=Configuration," & strDefaultNC)
oIADSUser.SetInfo

Function FindAnyMDB(strConfigurationNC)
	Dim oConnection
	Dim oCommand
	Dim oRecordSet
	Dim strQuery

	' Open the Connection.
	Set oConnection = CreateObject("ADODB.Connection")
	set oCommand = CreateObject("ADODB.Command")
	Set oRecordSet = CreateObject("ADODB.Recordset")

	oConnection.Provider = "ADsDSOObject"
	oConnection.Open "ADs Provider"

	' Build the query to find the private MDB.
	strQuery = "<LDAP://" & strConfigurationNC &
">;(objectCategory=msExchPrivateMDB);name,adspath;subtree"

	oCommand.ActiveConnection = oConnection
	oCommand.CommandText = strQuery
	Set oRecordSet = oCommand.Execute

	' If you have an MDB, return the first one.
	If Not oRecordSet.EOF Then
		oRecordSet.MoveFirst
		FindAnyMDB = CStr(oRecordSet.Fields("ADsPath").Value)
	Else
		FindAnyMDB = ""
	End If


	'Clean up.
	oRecordSet.Close
	oConnection.Close
	Set oRecordSet = Nothing
	Set oCommand = Nothing
	Set oConnection = Nothing
End Function

0
rpf (1)
9/16/2006 7:02:47 AM
exchange.admin 57650 articles. 2 followers. Follow

1 Replies
219 Views

Similar Articles

[PageSpeed] 2

You can't create a mailbox for a group.  You have to enumerate all users in 
the group and then create a mailbox for each.
-- 
Ed Crowley
MVP - Exchange
"Protecting the world from PSTs and brick backups!"

"prevs" <rpf@aapt.net.au> wrote in message 
news:1158390167.210955.77480@e3g2000cwe.googlegroups.com...
>I am writing a Active directory program, im stuck on the bit where I
> add mailboxes to accounts. I got some code of the microsoft website
> that creates a mailbox for a specified user, I need to create a mailbox
> for all users in a group called TaxGroup in the users container.Could I
> get some help modifying it to add the a Group.
>
> Dim oIADSUser
> Dim oMailbox
>
> Set oIADS = GetObject("LDAP://RootDSE")
> strDefaultNC = oIADS.Get("defaultnamingcontext")
> 'MsgBox FindAnyMDB("CN=Configuration," & strDefaultNC)
>
> 'TODO: Use the newly created domain user account to replace the
> "UserName".
> Set oIADSUser = GetObject("LDAP://CN=UserName,CN=Users," &
> strDefaultNC)
>
> If oIADSUser Is Nothing then
> MsgBox "The oIADSUser is Nothing."
> Else
> MsgBox "The oIADSUser is created successfully."
> End If
>
> Set oMailBox = oIADSUser
> oMailbox.CreateMailbox FindAnyMDB("CN=Configuration," & strDefaultNC)
> oIADSUser.SetInfo
>
> Function FindAnyMDB(strConfigurationNC)
> Dim oConnection
> Dim oCommand
> Dim oRecordSet
> Dim strQuery
>
> ' Open the Connection.
> Set oConnection = CreateObject("ADODB.Connection")
> set oCommand = CreateObject("ADODB.Command")
> Set oRecordSet = CreateObject("ADODB.Recordset")
>
> oConnection.Provider = "ADsDSOObject"
> oConnection.Open "ADs Provider"
>
> ' Build the query to find the private MDB.
> strQuery = "<LDAP://" & strConfigurationNC &
> ">;(objectCategory=msExchPrivateMDB);name,adspath;subtree"
>
> oCommand.ActiveConnection = oConnection
> oCommand.CommandText = strQuery
> Set oRecordSet = oCommand.Execute
>
> ' If you have an MDB, return the first one.
> If Not oRecordSet.EOF Then
> oRecordSet.MoveFirst
> FindAnyMDB = CStr(oRecordSet.Fields("ADsPath").Value)
> Else
> FindAnyMDB = ""
> End If
>
>
> 'Clean up.
> oRecordSet.Close
> oConnection.Close
> Set oRecordSet = Nothing
> Set oCommand = Nothing
> Set oConnection = Nothing
> End Function
> 


0
curspice6401 (3487)
9/19/2006 8:40:07 PM
Reply:

Similar Artilces:

Loadframe() fails when no menu is created
LoadFrame() fails to create a windows when no menu is create in the application. But the LoadFrame documentation from the MSDN library does not specifies that creating a menu with the IDR_MAINFRAME as resource identifier is mandatory for this function to succeed. begin quote MSDN Library LoadFrame requires fewer arguments than Create, and instead retrieves most of its default values from resources, including the frame's caption, icon, accelerator table, and menu. To be accessible by LoadFrame, all these resources must have the same resource ID (for example, IDR_MAINFRAME). end quote MSD...

Using OWC create Stack chart
Hi i would like to build Stack column chart of below sample data using owc please suggest method, Here "-" denotes the field break, Code, Price are two different fields. Code- Price X -5000 X-1000 Y-7000 Y-12000 Y-9000 Thanx ...

Creating Bookmarks in SharePoint
How do you create Bookmarks in SharePoint for a website? Please read the reply to your first posting. Alaska1 wrote: > How do you create Bookmarks in SharePoint for a website? ...

Problems managing multiple mailboxes
Hello, I've got Outlook 2002 and have set it up so I can manage multiple Exchange mailbox accounts per KB article 291626 (http://support.microsoft.com/kb/291626/en-us). It's been working fine for years, now all of a sudden when I go to open the other email accounts inbox (account B) when logged in as me (account A) it simply says "There are no items to show in this view." even though there are 121 new items showing next to the shortcut for this inbox in my Outlook Shortcuts tab. If I log in as account B, I can see these 121 items in the inbox so I know they are there...

Newbie How to : Move a control's position on a dialog
Hi All I have a control on a Dialog which I need to have displayed in a different position in different circumstances. .................................................................................................................... Control Id : ID_My_DTP Control Variable type : CDateTimeCtrl Control Variable name : m_ctrlDTP In the .rc file it is defined as CONTROL "DateTimePicker1",ID_My_DTP,"SysDateTimePick32", DTS_RIGHTALIGN | NOT WS_VISIBLE | WS_TABSTOP,262,49,56, 13,WS_EX_TRANSPARENT ............

Newbie question: Getting checked builds of Windows XP
Where does one get checked builds of Windows XP? I'd like to install just the checked OS and HAL (per this article: http://msdn.microsoft.com/en-us/library/ff547196.aspx), but there's no mention of where the checked versions of those files come from. It seems like this might be something one could get with an MSDN subscription, but after nosing around msdn.microsoft.com, I couldn't find a definitive answer; the MSDN download list for Windows XP (https://msdn.microsoft.com/en-us/subscriptions/securedownloads/default.aspx) shows checked builds for only a couple of e...

error when trying to install CRM for Outlook
We got the server installed and can connect to it via the browser. When I try to install the Sales for Outlook on my workstation, I get an error "Microsoft CRM Sales for Outlook cannot find an instance of the Microsoft CRM Server components at http://<<crm-server-url>>" I can hit that same url from my browser and the CRM app comes right up. Also, when trying to import contacts from Outlook it says "Microsoft Outlook cannot be started. Verify that Outlook is installed on this computer." Searched everywhere and can't find any procedure to fix this....

Can't restore mailbox from backup
I've just installed a Windows Small Business Server which comes with Exchange 2003 Standard. The problem is that I can't restore mailboxes. What am I doing wrong? Here is how I try to do it: - Backup using ntbackup utility in advanced mode MS Exchange server\First Storage Group - Create Recovery Storage Goup and then Connect Database - Mailbox Store. After this I have First Storage Group with Mailbox Store mounted and Recovery Storage Group with Mailbox Store unmounted. Folloing step is restore Mailbox Store from backup. I run ntbackup and in Select what to restore mark First ...

Creating ADD ONS
Suppose you have a VB6 application that is already completed, but you want to now add new functionality by way of ADD ONS that are purchased separately. What is the direction one would take to do this? For example, say you have a stock charting program and you want to make available various 'modules' that a user can purchase. When purchased and properly installed, it shows up under the ADDON menu that the user can now select and it will do its thing. This would be the first time I've tried to do something like this and I'm not sure what the approach is. Sugges...

how to create event boxes in excel
tell me how to create boxes in excel for timelines Jon Peltier has links to instructions for Gantt charts: http://www.peltiertech.com/Excel/Charts/GanttLinks.html bracer wrote: > tell me how to create boxes in excel for timelines -- Debra Dalgleish Excel FAQ, Tips & Book List http://www.contextures.com/tiptech.html ...

I loaded Office.Tried 2 load free Publshr.3hrslatrcantfindpg.
I got mesg. to download Office/Student.Then Publisher offered free trial.Friend & I tried for 2-3 hrs.Then after sone left 4 school, I've been trying different miscrosoft sites to find that page & can't.Can you please help me?I wld really like to try it?Thank you.My tech know-how is lmtd.But I try to do it self 1st.Thank you. What page can't you find? What did you try for 2 to 3 hrs? -- JoAnn Paules MVP Microsoft [Publisher] ~~~~~ How to ask a question http://support.microsoft.com/KB/555375 "10WHIZ2BE" <10WHIZ2BE@discussions.microsoft.com> wrote in...

CDO or Mapi for searching mailbox, sending mail
Hello guys, can you please advise which library is the most current and suitable for my task. I need to search and find mail in my mailbox based on sender and subject criteries, construct 'replay all' mail, edit it, attach files and send it. I see some of it can be done with CDO, all can be done with MAPI. However I am not sure which one should I use. ...

how can i create a box plot?
I need to create a box plot for an assignment. I'm using Excel 2003 and I don't have this option under tools nor under "add ins" Can anyone help me or give me advise? Try Jon Peltier's page at: http://www.peltiertech.com/Excel/Charts/ComboCharts.html#BoxWhisker Look for "Box and Whisker Plots" -- Rgds Max xl 97 --- GMT+8, 1� 22' N 103� 45' E xdemechanik <at>yahoo<dot>com ---- "Marina" <Marina@discussions.microsoft.com> wrote in message news:1DEFBDD0-D6F5-4FDA-A63B-BB0DB8CF48BF@microsoft.com... > I need to create a box p...

Create an image in VBA
Hiya, I have been given a task to do which involves generating a graph inside Access 2003 using VBA. I then have to output the image as a jpg, gif or bmp. I'm just in the early stage of planning this and I really have no idea which direction to go in at the moment because I have never done any image creation in VBA. Any suggestions of tutorials, tools or modules which may help will be appreciated Thanks, Alan On 4 Apr 2007 01:39:53 -0700, aclelland@gmail.com wrote: >Hiya, > >I have been given a task to do which involves generating a graph >inside Access 2003 using VBA. I...

Live Mail Bug
Problem: Using the "Move To" button actually creates a copy of an email, and does not remove it from the original location. This issue only seems to occur when you are using both Windows Live Mail (desktop client) and Windows Live Messenger at the same time. To reproduce: 1 - Launch and sign-in to both Mail and Messenger. 2 - When you receive an email, click the popup by the taskbar (the 'toaster popup') to automatically open the received email. 3 - Click 'Move To' and choose a folder other than your inbox. 4 - Close the mail message window an...

Query for AD to get E-mails With User Accounts & Creating New user Accounts !!
Hello everybody , i'm a newbie in Exchange Server who has it as heritage from a previous Admin. so what i need is (Maybe Simple): 1- a query (to get the output to a *.txt file) for AD to get all e-mails accounts associated with each user account .. so i can know in which OU it lives & how many E-mails it has. i've this but i don't know what parameter or where should i add to get the above details .. i just get e-mails: dsquery user "OU=Clients, DC=mydomain,DC=Com" | dsget user -email > C:\emails3.txt 2- Another query (or maybe command like dsadd) but i need to...

Create a dropdown
I would like to create a drop down cell that has a list of choices. How do I do this? Thank you You can use Data Validation. Debra Dalgleish has a web site that can get you started on this. http://www.contextures.com/xlDataVal01.html -- HTH, RD --------------------------------------------------------------------------- Please keep all correspondence within the NewsGroup, so all may benefit ! --------------------------------------------------------------------------- "Janice" <Janice@discussions.microsoft.com> wrote in message news:52F22B3F-5D6E-4C6F-B3E2-C44355412AF4@mi...

Using VBA to create folder
I have code that creates a bunch of csv files from the data in a workbook. Here are a couple of excerpts from my code: fldr = InputBox("Enter Directory Name", "CSV FILE LOCATION") .. .. .. Set fs = CreateObject("Scripting.FileSystemObject") If Not fs.FolderExists(fldr) Then fs.CreateFolder fldr End If If the user enters c:\joe\ and c:\joe\ doesn't exist, then the code will create a folder called c:\joe\. If the user enters c:\joe\bob\ and c:\joe\bob\ doesn't exist, then the code will create a folder called c:\joe\bob\ BUT ONL...

How To Create a Taskbar using Shell Extension
Dear All, I wish to create an additional taskbar on my monitor. Three days of dabbling in COM, and reading articles on Shell Extension (Code Project) has brought me no where near my problem. Kindly give me some pointers as to how to create a new taskbar. Many Thanks Rajan "rajan" <rajan@discussions.microsoft.com> wrote in message news:AA037443-4024-4AA9-ABBB-EA0A0D4447F6@microsoft.com... > Dear All, > > I wish to create an additional taskbar on my monitor. Three days of > dabbling > in COM, and reading articles on Shell Extension (Code Project) has broug...

creating signature cards for email
I am running exchange 5.5 on nt server. Outlook 2k is our email client. Question is there a way to create in exchange a default signature card that would appear on every outgoing user message, or is that something that would have to be done on each individual machine? Hi, Are you looking for sort of disclaimer text to be appended for every outgoing Internet mail? If so, can take a look at this http://support.microsoft.com/default.aspx?scid=kb;en-us;262097 neece "scott" <sgordon@fseg.net> wrote in message news:01ea01c3bf5f$7e9f18e0$a501280a@phx.gbl... > I am running e...

New calendar event(s) created in Outlook 2000 and 2003 do not appear in the calendar afterwards
I support approximately 40-50 end users at the installation I am at. These end users use either Outlook 2000 or Outlook 2003 as Exchange clients; the Exchange version being used is Exchange 2000. When a user creates a calendar event in Outlook, this event does not appear in the calendar after it has been created. Furthermore, this same event does not appear in other Outlook client's calendars either. Several users at my installation have reported this same problem. I have run one of the Outlook 2000 clients with the /CleanFreeBusy and /CleanReminders switches to no avail, with this prob...

Using Exmerge on a large mailbox (over 2 GB)
I want to export individual mailboxes and I am trying to use Exmerge on a mailbox that is larger than 2GBs. Exmerge seems to limit an export to 2Gbs. What options do I have? - Michael you'll need to do the export/s using a date range...you'll need to create pst files that are smaller than 2GB...how large is the maibox? "Michael McMahon" <mcmahon@spy.com> wrote in message news:PPHMe.1102$EZ5.486@fe08.lga... > I want to export individual mailboxes and I am trying to use Exmerge on a > mailbox that is larger than 2GBs. Exmerge seems to limit an export to 2Gbs....

duplicate mailboxes in microsoft outlook
I am in the process of migrating my mailboxes over to our new exchange 2003 server. I went into ADUC and right clicked the user id. I selected move mailbox under exchange tasks. Everything went smoothly. Then I created a new exchange profile pointing to the new server for the mailbox. Everything worked fine until I opened the mailbox and discovered there was the main mailbox and a duplicate one below it with my username. I went into the mail section of the control panel and checked it there and sure enough there were two distinct duplicate mailboxes. How do I get rid of the second box? ...

Move mailbox to different store on same server
Hi, I've got a single-server site with Exchange 2003 STD and am running into the 16GB message store size limit. I know that loading SP2 will expand this arbitrary limit to 75GB, but I'm also interested in segregating some special users' mailboxes into their own message store for administrative purposes. I've done a lot of searching, and while I've found several references to having mailboxes stored in one of many message stores on a single server, I have NOT found any references to the method to move a mailbox from one store to another without involving at least on...

Giving rights to a user's mailbox
I have a number of users that I have created in my Windows2003 domain that are giving me greif. I have been unable to assign permissions to their mailboxes to give other users the full mailbox right. When I go through the motions of giving the correct rights and then I try to open the mailbox in Outlook by telling it to open an aditional mailbox under the advanced tab I get an error of: Unable to expand the folder. The operation failed. An object could not be found. Any ideas? Thanks Mike Aditional: This is Exchange 2003 and Outlook 2003. I have also tried creating a new profile with t...