Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I've wrote the below script and most of it is functioning properly:
---------------------'VBScript
sub createou(x) 'Defining VBScript procedure
set dom = Getobject("LDAP://dc=swantafe,dc=edu,dc=au") 'Connecting to database
a= "OU=" & x
set ouExecutive = dom.create("organizationalunit", a) 'Creating the object (OU)
ouExecutive.setinfo
End subsub createuser(x)
set objou = Getobject("LDAP://ou=IT,dc=swantafe,dc=edu,dc=au")
a = "cn=" & x
set objusr = objou.create("User", c)
objuser.setinfo
end sub'Create main menu
do while y <> "q"
y = inputbox("Main menu" & VBcrlf & "1: Create user." & VBcrlf & "2: Create organisational unit." & VBcrlf & "q: Quit.")Select case y
Case "1"
z = inputbox("Enter username.")
createuser(z)
Case "2"
z = inputbox("Enter Organisational unit name.")
end select
loopHowever, everytime I try to create a user using it, it comes up with the following error:
Script: E:\folder\vbs\Create new OU or new user.vbs
Line: 12
Character: 1
Error: One or more input parameters are invalid.Code: 80005008
Source: Active DirectoryCould someone tell me what I've done wrong?
Life is but a dream ...

I'm assuming it's this line:
set objusr = objou.create("User", c)Question: Where is 'c' set? I don't see it.
Hint: When working with VBScript, make the very first line of code:
Option Explicit
It'll force you to declare your variables, which in tern saves you from a world of frustration.

Yes, the 'c' didn't belong there so I changed it. But I also found quite a few other errors on there that I've now sorted out. Thanks for your help!
Life is but a dream ...

'Create a new user:
Set objOU = GetObject("LDAP://OU=management,dc=fabrikam,dc=com")
Set objUser = objOU.Create("User", "cn=MyerKen")
objUser.Put "sAMAccountName", "myerken"
objUser.SetInfo'Create a new OU:
Set objDomain = GetObject("LDAP://dc=fabrikam,dc=com")
Set objOU = objDomain.Create("organizationalUnit", "ou=Management")
objOU.SetInfo
"Computer security." — Oxymoron

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |