WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADSI
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Error 222 with dsGetChildPath()

Keywords: 	  Error 222 dsGetChildPath()

Question:

The following code should work for anyone with AD:
strADRoot = dsGetProperty("LDAP://RootDSE", "DefaultNamingContext")
lstSubnets = dsGetChldPath("LDAP://cn=subnets,cn=sites,cn=configuration,%strADRoot%", "subnet")
In my case, it returns 222: Object cannot contain a specified class.

Is this because the container object's allowedChildClasses attribute is set to only one class (subnets)? I know in this case that means there should never be a non-subnet class object in this container, but I don't want a schema extension (by us or Microsoft) to break my script at some point in the future. Any ideas?

Answer:

This code fragment will not work for everyone. It will only work if the domain of the machine that is running the script happens to be the Forest Root Domain. Although the configuration information is replicated to all domains in the forest, it is seen as a child of the forest root for naming purposes. Use the "configurationNamingContext" property of rooDSE to obtain the configuration DN. Then use dsGetChldPath("LDAP://cn=subnets,cn=sites,%strADRoot%","subnet") to obtain your subnet info.

The specific error you mention is the result of a bug in the ADSI Extender. There is a new version of the extender (version 10007) that contains a fix for this problem. This version can be found in the usual place.

Question (cont'd):

The following code should work for anyone with AD:
strADRoot = dsGetProperty("LDAP://RootDSE", "DefaultNamingContext")
lstSubnets = dsGetChldPath("LDAP://cn=subnets,cn=sites,cn=configuration,%strADRoot%", "subnet")
In my case, it returns 222: Object cannot contain a specified class.

Is this because the container object's allowedChildClasses attribute is set to only one class (subnets)? I know in this case that means there should never be a non-subnet class object in this container, but I don't want a schema extension (by us or Microsoft) to break my script at some point in the future. Any ideas?

Answer:

Again you should be using the "configurationNamingContext" property instead of the "DefaultNamingContext" property. It is not the case that using "DefaultNamingContext" will work for all users. The following example works just fine using version 10007 on our local AD forest:
strADRoot = dsGetProperty("LDAP://RootDSE", "configurationNamingContext")
lstSubnets = dsGetChldPath("LDAP://cn=subnets,cn=sites,%strADRoot%","subnet")
Check the MS documention on the context sensitivity of "RootDSE".
Article ID:   W14762
File Created: 2001:11:08:12:39:52
Last Updated: 2001:11:08:12:39:52