Page 1 of 1 1
Topic Options
#123223 - 2004-07-19 02:58 PM Why can't I create a user in AD?
GSUK Offline
Starting to like KiXtart

Registered: 2004-03-10
Posts: 125
Hi there,

I have spent hours trying to work out where I am going wrong here. I have searched the bulletin board and my code looks right but I still cant get it to work! All I want to do is add a user to the NEW OU off the root of AD. Here's the code:

Code:
 
CLS
Break ON
$adsOU = GetObject("LDAP://OU=New,dc=domain,dc=com")
If @ERROR<>0
? @SERROR + " (" + @ERROR + ")"
Quit 1
EndIf

$adsUser = $adsOU.Create("user","cn=Test account34")
$adsOU.SetInfo



It doesn't flag up any errors

Thanks in advance for any help / suggestions

Glenn.

Top
#123224 - 2004-07-19 03:05 PM Re: Why can't I create a user in AD?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Should that not be (untested)
$adsUser.put "sAMAccountName", "Test account34"
$adsUser.SetInfo
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#123225 - 2004-07-19 03:09 PM Re: Why can't I create a user in AD?
GSUK Offline
Starting to like KiXtart

Registered: 2004-03-10
Posts: 125
Nope, that doesn't work either.

my understanding was that you have to create the account before you can put any data into it. I could be completely wrong though...

Top
#123226 - 2004-07-19 03:16 PM Re: Why can't I create a user in AD?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well, here is VBS from Micro$oft:
Code:
Set objOU = GetObject("LDAP://OU=management,dc=fabrikam,dc=com")
Set objUser = objOU.Create("User", "cn=MyerKen")
objUser.Put "sAMAccountName", "myerken"
objUser.SetInfo

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#123227 - 2004-07-19 05:04 PM Re: Why can't I create a user in AD?
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
This works...

Code:

$objOU = GetObject("LDAP://OU=YourOU,dc=YourCompany,dc=com")
@ERROR " | " @SERROR ?
$objUser = $objOU.Create("User", "cn=testuser")
$objUser.Put("sAMAccountName", "testuser")
$objUser.SetInfo


Top
#123228 - 2004-07-19 05:39 PM Re: Why can't I create a user in AD?
GSUK Offline
Starting to like KiXtart

Registered: 2004-03-10
Posts: 125
Excelent! I didn't realise I had to put the sAMAccountName in too. I was also setting info on the $adsOU and not the $adsUser.

Thanks for your help guys!


Top
#123229 - 2004-07-19 05:49 PM Re: Why can't I create a user in AD?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Then just what did you mean when you said "you have to create the account before you can put any data into it"?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.065 seconds in which 0.035 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org