Login | |
|
 |
Re: Create User Script - 7/1/2005 2:44:46 AM
|
|
 |
|
| |
cjwallace
Posts: 484
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
|
Hi Esnmb, Thanks very much for your reply. The code you have said to use above is already in the script. Any ideas as to what is going wrong? Thanks for your help so far. The Script so Far: <html> <HTA:APPLICATION APPLICATIONNAME="Withers LLP AD Account Creation" SCROLL="no" SINGLEINSTANCE="yes" WINDOWSTATE="normal" > <head> <title>Withers LLP User Account Creation Form</title> <style type="text/css"> <!-- .style3 {font-size: 13px} body,td,th { font-family: Arial, Helvetica, sans-serif; } .style2 { font-family: Arial, Helvetica, sans-serif; font-size: 13.5pt; color: #CC6600; font-weight: bold; } .style5 {font-size: small; color: #FF0000; } .style6 {color: #FF0000} --> </style> <script type="text/vbscript"> 'This section is the error reporting for the application Sub CreateAccount strUser = TextBox0.Value If strUser = "" Then MsgBox "You're missing required fields.",64, "Alert" Exit Sub End If strFirst = TextBox1.Value If strFirst = "" Then MsgBox "You're missing required fields",64, "Alert" Exit Sub End If strInitial = TextBox2.Value strLast = TextBox3.Value If strLast = "" Then MsgBox "You're missing required fields",64, "Alert" Exit Sub End If strDisplay = strFirst & ", " & strLast Const ADS_UF_ACCOUNTDISABLE = 2 Const ADS_PROPERTY_UPDATE = 2 ' This section will create the user & set part of the General Page. Set objOU = GetObject("LDAP://OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") Set objUser = objOU.Create("User", "cn=" & strUser) objUser.Put "sAMAccountName", LCase(strUser) objUser.Put "userPrincipalName", strUser & "@withers.net" objUser.SetInfo objUser.Put "givenName", strFirst If strInitial <> "" Then objUser.Put "initials", strInitial End If objUser.Put "sn", strLast objUser.Put "displayName", strDisplay ' This section will assign the user a standard password objUser.SetPassword "Passw0rd" objUser.Put "pwdLastSet", 0 intUAC = objUser.Get("userAccountControl") If intUAC And ADS_UF_ACCOUNTDISABLE Then objUser.Put"userAccountControl", intUAC Xor ADS_UF_ACCOUNTDISABLE End If objUser.SetInfo ' Address Page Information Set objUser = GetObject _ ("LDAP://cn=" & strUser & ",OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objUser.Put "streetAddress", "16 Old Bailey" objUser.Put "l", "London" objUser.Put "postalCode", "EC4M 7EG" objUser.Put "c", "GB" objUser.SetInfo ' General Page Information Set objUser = GetObject _ ("LDAP://cn=" & strUser & ",OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objUser.Put "physicalDeliveryOfficeName", "London" objUser.Put "telephoneNumber", "+44 (0)20 7597" objUser.Put "mail", "@withersworldwide.com" objUser.Put "wWWHomePage", "http://www.withersworldwide.com" objUser.SetInfo ' Users Telephone Information Set objUser = GetObject _ ("LDAP://cn=" & strUser & ",OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objUser.Put "facsimileTelephoneNumber", "+44 (0)20 7597 6543" objUser.SetInfo ' Organization Information Set objUser = GetObject _ ("LDAP://cn=" & strUser & ",OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objUser.Put "department", "Family Department" objUser.Put "company", "Withers LLP" objUser.SetInfo 'This Section Will Add the user to the Withers standard Security Groups Const ADS_PROPERTY_APPEND = 3 Set objGroup = GetObject _ ("LDAP://cn=LN London Users,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objGroup.PutEx ADS_PROPERTY_APPEND, _ "member", Array("cn=" & strUser & ",OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objGroup.SetInfo Set objGroup = GetObject _ ("LDAP://cn=LN Family,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objGroup.PutEx ADS_PROPERTY_APPEND, _ "member", Array("cn=" & strUser & ",OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objGroup.SetInfo Set objGroup = GetObject _ ("LDAP://cn=LN GWArchive,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objGroup.PutEx ADS_PROPERTY_APPEND, _ "member", Array("cn=" & strUser & ",OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objGroup.SetInfo ' Users Home & Profile Information
|
|
| |
|
|
|
 |
Re: Create User Script - 7/1/2005 2:54:53 AM
|
|
 |
|
| |
esnmb
Posts: 431
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
|
Also, when you add the user to groups, you most likely will need to replace strUser with strCN: Set objGroup = GetObject _ ("LDAP://cn=LN London Users,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objGroup.PutEx ADS_PROPERTY_APPEND, _ "member", Array("cn=" & strCN & ",OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objGroup.SetInfo
|
|
| |
|
|
|
 |
Re: Create User Script - 7/1/2005 3:03:26 AM
|
|
 |
|
| |
cjwallace
Posts: 484
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
|
Thanks for your help on this. Ok, that has done what i want it to, BUT and here is the but. When i run the script i get Line: 89 Char: 1 Error: There is no such object on the server. And when i go into the account that it has created all my info such as profile directorys, Address page info is blank. The Code So far with the changes. <html> <HTA:APPLICATION APPLICATIONNAME="Withers LLP AD Account Creation" SCROLL="no" SINGLEINSTANCE="yes" WINDOWSTATE="normal" > <head> <title>Withers LLP User Account Creation Form</title> <style type="text/css"> <!-- .style3 {font-size: 13px} body,td,th { font-family: Arial, Helvetica, sans-serif; } .style2 { font-family: Arial, Helvetica, sans-serif; font-size: 13.5pt; color: #CC6600; font-weight: bold; } .style5 {font-size: small; color: #FF0000; } .style6 {color: #FF0000} --> </style> <script type="text/vbscript"> 'This section is the error reporting for the application Sub CreateAccount strUser = TextBox0.Value If strUser = "" Then MsgBox "You're missing required fields.",64, "Alert" Exit Sub End If strFirst = TextBox1.Value If strFirst = "" Then MsgBox "You're missing required fields",64, "Alert" Exit Sub End If strInitial = TextBox2.Value strLast = TextBox3.Value If strLast = "" Then MsgBox "You're missing required fields",64, "Alert" Exit Sub End If strDisplay = strFirst & ", " & strLast strCN = strLast & "\, " & strFirst Const ADS_UF_ACCOUNTDISABLE = 2 Const ADS_PROPERTY_UPDATE = 2 ' This section will create the user & set part of the General Page. Set objOU = GetObject("LDAP://OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") Set objUser = objOU.Create("User", "cn=" & strCN) rem Set objUser = objOU.Create("User", "cn=" & strUser) objUser.Put "sAMAccountName", LCase(strUser) objUser.Put "userPrincipalName", strUser & "@withers.net" objUser.SetInfo objUser.Put "givenName", strFirst If strInitial <> "" Then objUser.Put "initials", strInitial End If objUser.Put "sn", strLast objUser.Put "displayName", strDisplay ' This section will assign the user a standard password objUser.SetPassword "Passw0rd" objUser.Put "pwdLastSet", 0 intUAC = objUser.Get("userAccountControl") If intUAC And ADS_UF_ACCOUNTDISABLE Then objUser.Put"userAccountControl", intUAC Xor ADS_UF_ACCOUNTDISABLE End If objUser.SetInfo ' Address Page Information Set objUser = GetObject _ ("LDAP://cn=" & strUser & ",OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objUser.Put "streetAddress", "16 Old Bailey" objUser.Put "l", "London" objUser.Put "postalCode", "EC4M 7EG" objUser.Put "c", "GB" objUser.SetInfo ' General Page Information Set objUser = GetObject _ ("LDAP://cn=" & strUser & ",OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objUser.Put "physicalDeliveryOfficeName", "London" objUser.Put "telephoneNumber", "+44 (0)20 7597" objUser.Put "mail", "@withersworldwide.com" objUser.Put "wWWHomePage", "http://www.withersworldwide.com" objUser.SetInfo ' Users Telephone Information Set objUser = GetObject _ ("LDAP://cn=" & strUser & ",OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objUser.Put "facsimileTelephoneNumber", "+44 (0)20 7597 6543" objUser.SetInfo ' Organization Information Set objUser = GetObject _ ("LDAP://cn=" & strUser & ",OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objUser.Put "department", "Family Department" objUser.Put "company", "Withers LLP" objUser.SetInfo 'This Section Will Add the user to the Withers standard Security Groups Const ADS_PROPERTY_APPEND = 3 Set objGroup = GetObject _ ("LDAP://cn=LN London Users,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objGroup.PutEx ADS_PROPERTY_APPEND, _ "member", Array("cn=" & strUser & ",OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objGroup.SetInfo Set objGroup = GetObject _ ("LDAP://cn=LN Family,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objGroup.PutEx ADS_PROPERTY_APPEND, _ "member", Array("cn=" & strUser & ",OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objGroup.SetInfo
|
|
| |
|
|
|
 |
Re: Create User Script - 7/1/2005 3:08:50 AM
|
|
 |
|
| |
esnmb
Posts: 431
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
|
Give this a try: <html> <HTA:APPLICATION APPLICATIONNAME="Withers LLP AD Account Creation" SCROLL="no" SINGLEINSTANCE="yes" WINDOWSTATE="normal" > <head> <title>Withers LLP User Account Creation Form</title> <style type="text/css"> <!-- .style3 {font-size: 13px} body,td,th { font-family: Arial, Helvetica, sans-serif; } .style2 { font-family: Arial, Helvetica, sans-serif; font-size: 13.5pt; color: #CC6600; font-weight: bold; } .style5 {font-size: small; color: #FF0000; } .style6 {color: #FF0000} --> </style> <script type="text/vbscript"> 'This section is the error reporting for the application Sub CreateAccount strUser = TextBox0.Value If strUser = "" Then MsgBox "You're missing required fields.",64, "Alert" Exit Sub End If strFirst = TextBox1.Value If strFirst = "" Then MsgBox "You're missing required fields",64, "Alert" Exit Sub End If strInitial = TextBox2.Value strLast = TextBox3.Value If strLast = "" Then MsgBox "You're missing required fields",64, "Alert" Exit Sub End If strDisplay = strFirst & ", " & strLast strCN = strLast & "\, " & strFirst Const ADS_UF_ACCOUNTDISABLE = 2 Const ADS_PROPERTY_UPDATE = 2 ' This section will create the user & set part of the General Page. Set objOU = GetObject("LDAP://OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") Set objUser = objOU.Create("User", "cn=" & strCN) rem Set objUser = objOU.Create("User", "cn=" & strUser) objUser.Put "sAMAccountName", LCase(strUser) objUser.Put "userPrincipalName", strUser & "@withers.net" objUser.SetInfo objUser.Put "givenName", strFirst If strInitial <> "" Then objUser.Put "initials", strInitial End If objUser.Put "sn", strLast objUser.Put "displayName", strDisplay ' This section will assign the user a standard password objUser.SetPassword "Passw0rd" objUser.Put "pwdLastSet", 0 intUAC = objUser.Get("userAccountControl") If intUAC And ADS_UF_ACCOUNTDISABLE Then objUser.Put"userAccountControl", intUAC Xor ADS_UF_ACCOUNTDISABLE End If objUser.SetInfo ' Address Page Information Set objUser = GetObject _ ("LDAP://cn=" & strCN & ",OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objUser.Put "streetAddress", "16 Old Bailey" objUser.Put "l", "London" objUser.Put "postalCode", "EC4M 7EG" objUser.Put "c", "GB" objUser.SetInfo ' General Page Information objUser.Put "physicalDeliveryOfficeName", "London" objUser.Put "telephoneNumber", "+44 (0)20 7597" objUser.Put "mail", "@withersworldwide.com" objUser.Put "wWWHomePage", "http://www.withersworldwide.com" objUser.SetInfo ' Users Telephone Information objUser.Put "facsimileTelephoneNumber", "+44 (0)20 7597 6543" objUser.SetInfo ' Organization Information objUser.Put "department", "Family Department" objUser.Put "company", "Withers LLP" objUser.SetInfo 'This Section Will Add the user to the Withers standard Security Groups Const ADS_PROPERTY_APPEND = 3 Set objGroup = GetObject _ ("LDAP://cn=LN London Users,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objGroup.PutEx ADS_PROPERTY_APPEND, _ "member", Array("cn=" & strCN & ",OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objGroup.SetInfo Set objGroup = GetObject _ ("LDAP://cn=LN Family,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objGroup.PutEx ADS_PROPERTY_APPEND, _
|
|
| |
|
|
|
 |
Re: Create User Script - 7/1/2005 3:09:26 AM
|
|
 |
|
| |
cjwallace
Posts: 484
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
|
quote: Originally posted by esnmb Also, when you add the user to groups, you most likely will need to replace strUser with strCN: Set objGroup = GetObject _ ("LDAP://cn=LN London Users,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objGroup.PutEx ADS_PROPERTY_APPEND, _ "member", Array("cn=" & strCN & ",OU=FAMILY,OU=LONDON USERS,OU=WITHERS USERS,dc=withers,dc=net") objGroup.SetInfo
Thanks for the reply mate. Ok i have strUser all over my script which works a treat. do i need to replace everything that has strUser with strCN?
|
|
| |
|
|
|
 |
Re: Create User Script - 7/1/2005 3:27:32 AM
|
|
 |
|
| |
esnmb
Posts: 431
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
|
My pleasure, really. I think it can be done like so: objUser.Put "physicalDeliveryOfficeName", "London" objUser.Put "telephoneNumber", "+44 (0)20 7597" objUser.Put "mail", strFirst & "." & strLast & "@withersworldwide.com" objUser.Put "wWWHomePage", "http://www.withersworldwide.com" objUser.SetInfo If that doesn't work, make a variable with that info: strMail = strFirst & "." & strLast & "@withersworldwide.com" objUser.Put "physicalDeliveryOfficeName", "London" objUser.Put "telephoneNumber", "+44 (0)20 7597" objUser.Put "mail", strMail objUser.Put "wWWHomePage", "http://www.withersworldwide.com" objUser.SetInfo
|
|
| |
|
|
|
 |
Re: Create User Script - 7/1/2005 3:35:16 AM
|
|
 |
|
| |
esnmb
Posts: 431
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
|
But, to create an Exchange mailbox you may find this useful: ' Creates the users mailbox Set oIADSUser = GetObject("LDAP://CN=" & strCN & "," & strLDAP) oIADSUser.CreateMailbox "LDAP://CN=Mailbox Store (EXCHANGE),CN=First Storage Group,CN=InformationStore,CN=ExchangeServerName,CN=Servers,CN=MIDDLETOWN,CN=Administrative Groups,CN=Site,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=domain,DC=com" oIADSUser.SetInfo Watch for word wrapping. If you are unsure of the whole LDAP string for your Exchange environment, open up ADSIEdit and drill down in the configuration by following the LDAP string in my example in reverse order to find yours. Once you find your CN=Mailbox Store, right click on it and go to properties ,and get the distinguishedName.
< Message edited by esnmb -- 1/2/2007 5:35:33 AM >
|
|
| |
|
|
|
|
|