?
Solved

add mulitiply SMTPs to an account when creating in VBS

Posted on 2010-11-29
3
Medium Priority
?
582 Views
Last Modified: 2012-06-27
Hi,
  i have created a vbs script to create a user in AD with a primary SMTP address.  Now i would like to add several SMTP addresses instead of just the one.  i am having trouble getting ubound to work with an array of addresses.  can someone please point me in the right direction?

 
set objOU = GetObject("LDAP://OU=TEST,DC=MYDOMAIN,DC=NET")
Set objUser = objOU.Create("User", "cn=" & last & "\, " & strUser) 
	if (err.Number<>0) Then
		MsgBox("An error has occurred. Object Could Already Exist.  Error:" & Err.Number)
    End If
objUser.Put "givenName", strUser
objUser.Put "sn", last
objUser.Put "displayName", last & ", " & strUser
objUser.Put "description", des
objUser.Put "physicalDeliveryOfficeName", off
objUser.Put "telephoneNumber", tele
objUser.Put "mail", strUser & "." & last & domainEmail
objUser.Put "sAMAccountName", strUser & "." & last
objUser.Put "streetAddress", st
objUser.Put "postOfficeBox", pb
objUser.Put "l", ct
objUser.Put "st", sOrp
objUser.Put "postalCode", zOrp
objUser.Put "countryCode", coCode
objUser.Put "co", countcode
objUser.Put "c", cAbr
ObjUser.Put "userPrincipalName", strUser & "." & last & domainEmail
ObjUser.Put "scriptPath", scr
ObjUser.Put "title", ti
ObjUser.Put "department", dep
ObjUser.Put "company", com
ObjUser.Put "mydomain-MailboxSize","100"
ObjUser.Put "mydomain-DataCenter","UNITED STATES"
ObjUser.Put "mydomain-EmailAddresses", "SMTP:" & strUser & "." & last & domainEmail

ObjUser.SetInfo

ObjUser.accountDisabled = False
ObjUser.setPassword pass
ObjUser.SetInfo

Open in new window

0
Comment
Question by:supportAB
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 71

Expert Comment

by:Chris Dent
ID: 34230951

Have you considered using ADS_PROPERTY_APPEND?

e.g.

Const ADS_PROPERTY_APPEND = 3

ObjUser.PutEx ADS_PROPERTY_APPEND, "myDomain-EmailAddresses", Array("smtp:newaddress1@domain.com")
ObjUser.SetInfo

I assume "mydomain-EmailAddresses" is the correct field (that is, this is not Exchange and therefore proxyAddresses), and that the field is really an array?

You'd potentially loop through each user doing that (SetInfo each time), so I advise that you put it after user creation is finalised.

Chris
0
 
LVL 26

Accepted Solution

by:
Tony J earned 2000 total points
ID: 34231602
Const ADS_PROPERTY_APPEND = 3
Set objUser = GetObject (“LDAP://path of the user“)

Set filesys = CreateObject(“Scripting.FileSystemObject”)
set filetxt = filesys.openTextfile(“c:\Names.txt”,1)
do until filetxt.AtEndofStream
 name = filetxt.readline
 name = trim(name)
 objUser.PutEx ADS_PROPERTY_APPEND, “proxyAddresses”, Array(“smtp:” & name)
 objUser.SetInfo

Loop
0
 

Author Closing Comment

by:supportAB
ID: 34238954
thank you so much
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question