cscript name_of_file.js "user to find"
var username, rootDSE, domainNC, connection, command, recordset;
var voice = new ActiveXObject("SAPI.SpVoice");
username = WScript.Arguments.Item(0);
rootDSE = GetObject("LDAP://rootDSE");
domainNC = rootDSE.Get("defaultNamingContext");
connection = new ActiveXObject("ADODB.Connection");
connection.Open("Provider=ADsDSOObject;");
command = new ActiveXObject("ADODB.Command");
command.ActiveConnection = connection;
command.CommandText = ";" +
"(sAMAccountName=" + username + ");" +
"CN,telephoneNumber;subtree";
command.Properties("Cache Results") = false;
command.Properties("Page Size") = 100;
recordset = command.Execute();
while (! recordset.EOF) {
voice.Speak(recordset.Fields.Item("CN").Value);
WScript.Echo(recordset.Fields.Item("CN").Value + "\t" +
recordset.Fields.Item("telephoneNumber").Value);
recordset.MoveNext();
}
connection.Close();
No comments:
Post a Comment