I'm not familiar with dsquery...

but if you could provide an example of what that shell is expected to return exactly, I'm willing to bet there is an all Kix method of getting it. Eliminating the need to shell out to the command prompt all together.