Q. How can I use a script to bulk-mail-enable users?
May 26, 2004
A. I modified the script in the FAQ "How can I use a script to mail-enable a user--that is, give the user email address attributes in Active Directory (AD)?" to read from a text file that contains three values per line: the user's distinguished name (DN), email address prefix, and nickname. A pipe (|) character delimits the values, so the file format looks like
<user's DN>|<email address prefix>|<user's nickname>
Here's an example of a file that a script could read:
cn=no mail,cn=users,dc=demo,dc=local|nomail|No mailcn=no mail2,cn=users,dc=demo,dc=local|nomail2|No mail2
Save these lines in a file--for example, d:temptomailenable.txt. Then, run the following blkmailenable.vbs script (a modified version of mailenable.vbs) to read and process the entries from the file. (Some lines are wrapped because of space constraints.) You can download the script at Code.
Dim sTarget, sProxy, sUserConst ForReading = 1Set oFSO = CreateObject("scripting.filesystemobject")Set oTF = oFSO.OpenTextFile("d:temptomailenable.txt", _ ForReading, True)Do While oTF.AtEndOfStream TruesLine = oTF.ReadLineaLine = split(sline, "|", -1, 1)sDN = aLine(0)sMail = aLine(1)sMailNick = aLine(2)On Error Resume NextsUser = "LDAP://" & sDNWScript.Echo sUserSet oUser = GetObject(sUser)oUser.put "mail", sMail & "@netscape.savilltech.com"oUser.put "mailnickname", sMailNickoUser.put "DisplayName", sMailNickoUser.put "proxyAddresses", Array("SMTP:" & sMail & _ "@netscape.savilltech.com", "smtp:" & sMail & "@savilltech.com")oUser.put "targetAddress", "SMTP:" & sMail & _ "@netscape.savilltech.com"
Blkmailenable.vbs opens the file specified in the oTF variable and reads one line at a time. For each line in the file, the script connects the username that's specified by the DN and creates two email addresses for the user: a primary address of <email prefix>@netscape.savilltech.com and a secondary address of <email prefix>@savilltech.com.
About the Author
You May Also Like