HI All,thought i had to say something here...
When you start using ADSI in combination with Kix2K the following rules apply:
The script must be run on a machine that is either Windows 2K or up OR an NT4 machine that has ADSI installed (get it at MS).
Also, when you are targeting NT4 machines with ADSI, you must use the WinNT: provider, you can only use the LDAP: provider when you are targeting W2K machines (Active Directory)
As long as you are using the WinNT provider you don't need any prereqs on them servers.
There are some other problems to be overcome when using ADSI, i am working in an environment of 110+ NT4 domains, all remote, no trust relations and without WINS replication. hence to succesfully connect to a remote server i first need to check one of the possible release levels which indicates the passwords to use, i have done this through a small piece of code that reads a ini file with some of the combinations and try and map to an administrative share.
code:
$connstatus = "not connected"
for each $adminstring in split(readprofilestring($inifile,"admins",""),chr(10))
if $connstatus <> "connected"
if $adminstring
$tempstring = split($adminstring, ";")
$adminname = $tempstring[0]
$adminpw = $tempstring[1]
$admindesc = $tempstring[2]
use x: "\\$homeserver\c$" /user:$adminname /password:$adminpw
select
case @error = 0
$connuser = $adminname
$connpw = $adminpw
$connstatus = "connected"
case @error = 53
? "Error connecting to " + $domain + "."
return
endselect
endif
endif
next
net use x: /delete
i don't use that share to give me the proper ADSI rights, i prefer a connection with adsi passing credentials.
Another problem is the lack of WINS, as adsi tries to connect to a domain, it looks for the Netbios 1B and 1C entries. Normally with WINS replicating all your domains, this is no problem. to do it with an LMHOSTS entry you need a double entry like this (Servername = Myserver and domainname = Mydomain, ip = 1.2.3.4, Myserver is the PDC for Mydomain)
1.2.3.4 Myserver #PRE #DOM:Mydomain
1.2.3.4 "Mydomain \0x1b" #PRE
NOTE the board corrupts formatting, but between Mydomain and \0x1b there should be enough spacing (no tabs!!) so that the \ is the 16th character (IMPORTANT !!) this has to do with Netbios being 16 bytes long, 15 chars for the name and one byte for the type (1B, 1C, 03, 00 etc)
Now you can use ADSI to connect to Mydomain without any problems. to use ADSI for passing credentials use :
$root = Getobject ("WinNT:")
$dm = $root.opendsobject("WinNT://$Mydomain,domain","$connuser","$connpw",1)
where $Mydoamin is the domain to connect to and $connuser is administrative useraccount and $connpw is the password for that account.
for all other tricks concerning checking of,modifying and creating users pls refer to other recent posts that covered this.
Hope this clarifies a little on ADSI.
Ciao,
MvdW
(ps i learned it all from Shawn ..
)
[ 05 September 2001: Message edited by: mvdw ]