Link to home
Start Free TrialLog in
Avatar of mikey250
mikey250

asked on

visual basic - command order sequence

hi ive successfully created for the 1st time the following on windows 2003:

- a 'ou, group & user account' - via visual basic

ive now added some other information to go in a 'domain user account' but no matter where i put it, it appears not to work & im aware there is obviously some order to it but have not got a clue!!

in order to get the extras ive added, i accessed 'adsiedit.msc' & ticked a box in order to see what they were on another user account that i created manually.

qns1.  can anyone help me to put in order & some advice maybe ?

note: ive been doing some reading & whatching videos to gain some basic understanding as always wondered about these so-called 'scripts' & begginning to understand why some can be useful somewhat!!
CreateUserinGroup.vbs
Avatar of shorvath
shorvath
Flag of Canada image

Try this:

Set objOU = GetObject("LDAP://OU=Coding Samples,dc=itservices,dc=co.uk")
Set objUser = objOU.Create("User", "cn=Test User7")
objUser.Put "sAMAccountName", "Test User7"
objUser.SetInfo

objUser.SetPassword "adminpw!1"
objUser.SetInfo

objUser.AccountDisabled = FALSE
objUser.Department = "Engineering Department"
objUser.Description = "User Account"
objUser.FaxNumber = "01902356756"
objUser.FullName = "James C. Foster"
objUser.TelephoneHome = "01902356756"
objUser.TelephoneMobile = "07814789674"
objUser.TelephoneNumber = "01902 356756"
objUser.EmailAddress = "jamesf@itservices.co.uk"
objUser.Manager = "CN=james c.foster,OU=ACCTS,DC=itservices,DC=co.uk"
objUser.SetInfo

Open in new window


When using the objUser, you can only set IADsUser interface properties..

See this link for a list.   http://msdn.microsoft.com/en-us/library/aa746340(VS.85).aspx

After the user is created, you could then modify other AD attributes.  See link below

http://msdn.microsoft.com/en-us/library/cc221082.aspx
Avatar of mikey250
mikey250

ASKER

hi shorvath, (i will have a look through the url's so thanks)!!!!

i assumed it would create inside my 'coding samples' i have created already for the others i did, individually but i wanted to created all at once the: ou, group & user, but got the following message:

createusergroup.vbs

line 4
char 1
error - the object already exists
code - 80071392
source - (null)
well , if the user already exists, it's going to throw and error.

there are lots of ways to test if a user exists, and then add if he/she does not...
hi shorvath, apologies for taking time to respond. you will have to forgive my slowness as all i see is code that dont make no sense to me yet!!!!!!!!!!

step 1

i deleted user from: coding samples but still states:

line 19
char 1
error - there is no such object on the server

but user account: test user8 - does appear with red (x)

step 2

deleted 'coding samples'
created manually 'coding samples'

step 3
ran script - but still below shows:

line 19
char 1
error - there is no such object on the server

but user account: test user8 - does appear with red (x)

step 4

added 'coding samples3' in vbs script but same issue:

line 19
char 1
error - there is no such object on the server

but user account: test user8 - does appear with red (x)
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hi robsampson, i have not forgotten this and i will come back to this question, just finishing something else off!!  appreciated.
That's OK.  I'll be around ;-)
I've requested that this question be deleted for the following reason:

The question has either no comments or not enough useful information to be called an "answer".
I believe my comment ID 38886979 provides a decent answer.
hi robsampson, yes in the end i got it to work and updated my server at the same time with some unknown missing updates.

although that was not my question really it was after creating an 'ou & a user account' i wanted to add all other company details in the user account such as mobile phone, email address, name of company.

because of this i used the 'adsiedit.msc' to know what specific word code needs to be used, but when i added it, it would not work!!!

apologies for taking sometime to come back!!!!