Question : ADSI Script problem : How do I access/modify objects in different domain ?

Hi There,

We have 2 domains here. Domain_old and Domain_new
Currently I'm writing an ADSI script which runs on a computer logged on to Domain_old and it has a sub routine which should echo group name in the target domain (ie. Domain_new)

Now I get an error saying : "Provider: : Table does not exist"

The code snippet from the subroutine is attached below.

Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
'*****************************Script******************************
 
Const ADS_SCOPE_SUBTREE = 2
 
Sub enumerateTDGroups()
	Set oRoot = GetObject("LDAP://Domain_new/RootDSE") 
	sDNSDomain = oRoot.Get("DefaultNamingContext") 
	msgbox sDNSDomain
	
	Set objConnection = CreateObject("ADODB.Connection")
	Set objCommand =   CreateObject("ADODB.Command")
	objConnection.Provider = "ADsDSOObject"
	
	objConnection.Properties("User ID") = "Domain_new\AdminAccount"
	objConnection.Properties("Password") = "password123"
	objConnection.Properties("Encrypt Password") = TRUE
	objConnection.Properties("ADSI Flag") = 3
	
	objConnection.Open "Active Directory Provider"
	Set objCommand.ActiveConnection = objConnection
	
	objCommand.Properties("Page Size") = 9999
	objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
	
	objCommand.CommandText = _
	    "SELECT adspath FROM 'LDAP://"& sDNSDomain &"' WHERE objectCategory='group'"
	
	Set objRecordSet = objCommand.Execute
	
	objRecordSet.MoveFirst
	Do Until objRecordSet.EOF
	    Wscript.Echo objRecordSet.Fields("adspath").Value
	    objRecordSet.MoveNext
	Loop
End Sub
Open in New Window Select All

Answer : ADSI Script problem : How do I access/modify objects in different domain ?

pedalhead,

No I'm not migrating the users. by the way I got the answer to the question I changed the line
"SELECT adspath FROM 'LDAP://"& sDNSDomain &"' WHERE......

to
"SELECT adspath FROM 'LDAP://Domain_New/"& sDNSDomain &"' WHERE .......

and it returned the data as  required.
Random Solutions  
 
programming4us programming4us