/***********************************************************************
* Simple script to dump an ads query to a file 
* not quite as useful as it once was
*  yasth a symbol yasth .. org
*
*************************************************************************/

var fname = "all.txt";			//This is the output Filename
var pattern = "bl-libg-t*";	//Patern to search for this uses a kind of odd not quite sql
var classType = "computer";	//computer user group whatever
fs = new ActiveXObject("Scripting.FileSystemObject");
os = fs.CreateTextFile(fname, true);
ADS_SCOPE_SUBTREE = 2;
objConnection = new ActiveXObject("ADODB.Connection");
objCommand = new ActiveXObject("ADODB.Command");
objConnection.Provider = "ADsDSOObject";
objConnection.Open("Active Directory Provider");
objCommand.ActiveConnection = objConnection;
objCommand.CommandText = "Select Name from 'LDAP://DC=ads,DC=iu,DC=edu'  where objectClass='"+classType+"'and Name = '" +pattern + "'";
objCommand.Properties("Page Size") = 10;
objCommand.Properties("Timeout") = 30;
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE;
objCommand.Properties("Cache Results") = false;
objRecordSet = objCommand.Execute;
objRecordSet.MoveFirst;
do{
os.WriteLine(objRecordSet.Fields("Name").Value);
objRecordSet.MoveNext;
 }while(!objRecordSet.EOF);