Page 1 of 1 1
Topic Options
#84815 - 2002-01-07 11:17 PM syntax on LDAP in AD
mvdw Offline
Starting to like KiXtart

Registered: 2001-05-01
Posts: 124
Loc: Voorburg, Netherlands
Hi there,

first off, happy new year to everybody !!
here comes the questions:

i've been playing around for a while now with adsi (read: the WinNT provider). After a few great pointers and sample scripts from you guys i can now script almost anything with this provider. But now i have a new challenge in my life... create a contact in AD, in a script.

pls note that i am a NT4 admin, 2k knowledge is limited

i figured that my best bet was the LDAP provider since there are some limitations in the WinNT provider. I'd like to bind to the (contacts) container(/OU) in the domain, create the contact object, and set its properties. (just like i would create a user on NT4).

problem : binding to the container

consider my setup, 1 W2K DC, with AD installed (only server in domain), hooked up to 1 W2K prof machine running the scripts, NOT part of any domain. The domain (mvdw.nl) contains a OU called "contacts" in the root of AD

My thought :
$LDAP = getobject ("LDAP:")
$ou = $LDAP.opendsobject ("LDAP:// ... ","administrator","SecReT",1)

$ou.create etc etc ...

but as you can see by the ... i can't seem to get the syntax right to bind to the ou. tried just about any combination i could find in SDK/MSDN but all of them returned an error.

can anyone enlighten me what the correct syntax of this would be ??
if i have just one working example i should be able to figure out the rest of this to also work using getobject directly and in other domains/ou's

Thanks in advance.

_________________________
rgrds, Maarten

Top
#84816 - 2002-01-07 11:54 PM Re: syntax on LDAP in AD
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Maarten

What @SERROR are you getting on the opendsobject ?

-Shawn

I don't have an AD domain to try this code on, but i would imagine it would be something like this (admin rights and opendsobject aside) ...


break on


$container = getobject("LDAP://OU=contacts,DC=mvdw,DC=nl")


if $container
?"yippie"
else
?"crap"
endif


exit


Untested !!!

-Shawn

[ 08 January 2002: Message edited by: Shawn ]

Top
#84817 - 2002-01-08 12:28 AM Re: syntax on LDAP in AD
mvdw Offline
Starting to like KiXtart

Registered: 2001-05-01
Posts: 124
Loc: Voorburg, Netherlands
Shawn,

tried that and got :
-2147023541
The specified domain either does not exist or could not be contacted.

i also tried variations, but because i just set up AD about two hours ago, i could have missed something...

i did manage to get past the "specified domain could not be..." message, into some opendsobject errors (the ones with [1]/[1] at the end.)

is there a way to quickly check the name of the container on the server itsself ??

if i use :
$container = getobject("LDAP://mvdw.nl/contacts")
i get :
-2147016646
The server is not operational.

is that a prob on the server or in the syntax ? since i am using only one server, i thought it would be OK, or should i put the server name in there somewhere also ? (connserver)

have i misconfigured anything (i ran the AD setup wizard and added the dns server to the workstation in dhcp.

C:\>ping connserver.mvdw.nl

Pinging connserver.mvdw.nl [10.0.0.151] with 32 b

Reply from 10.0.0.151: bytes=32 time<10ms TTL=128

that doesn't seem to be the problem ...

_________________________
rgrds, Maarten

Top
#84818 - 2002-01-08 02:57 AM Re: syntax on LDAP in AD
Alex.H Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 406
Loc: France
Maarten,
You should try to play a little with the Adsearch UDF (too lazy to retreive the link in the UDF section). It will give you some idea of the naming context in AD
Beware, as this function add 2 informations that are not comming from AD : Accountname, Iscontainer and IsGroup.

With LDAP, if you want to retreive someting as an objet, you have to give his full context name (CN) in THE RIGHT ORDER!!!!!
(sometimes, I would like M$ not getting so strict, but i think it's a dream). Also, no wildcards or errors are tolerated but seems that after all, M$ drop us something, as even if it's case sensitive (!one more!), i've already got it working with all in lower case.

For your example, it's most something like
$container = getobject("LDAP://mvdw.nl/OU=contacts,DC=mvdw,DC=nl")

[ 08 January 2002: Message edited by: Alex.H ]

_________________________
? getobject(Kixtart.org.Signature)

Top
Page 1 of 1 1


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

Who's Online
0 registered and 2312 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.096 seconds in which 0.07 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