我正在尝试创建我的第一个应用程序。我想创建一个从Active Directory提取某些用户属性的脚本。我创建了一个HTA应用程序,但它不起作用。我真的需要您的一些支持。
谢谢。
这是html代码[hta app
这是脚本详细信息:
<script type="VBscript">
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = ("ADsDSOObject")
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
objCommand.Properties("SearchScope") = 2
objCommand.CommandText = "SELECT userWorkstations,sAMAccountName,Mail,name,DisplayName,distinguishedName,LastLogonDate, FROM 'LDAP://dc=NESTLE,dc=com' WHERE objectCategory='user' AND displayname='" & VaR5 & "'"
Set objRecordSet = objCommand.Execute
</script>
<hta:application
applicationname="ADUCUserGrab"
border="thin"
borderstyle="normal"
caption="ADUC User Grab"
contextmenu="yes"
icon="aduc_sm.ico"
maximizebutton="no"
minimizebutton="yes"
navigable="yes"
scroll="yes"
selection="yes"
showintaskbar="yes"
singleinstance="yes"
sysmenu="yes"
version="1.0"
windowstate="normal"
>
</head>
这是html代码[.hta app]:
<body topmargin="1" leftmargin="0" rightmargin="0" bottommargin="1" bgcolor="#000080" text="#FFFFFF">
<table border="0" width="640" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="top" height="110" bgcolor="#000080">
<i>Enter the <u>userid</u> or <u>last name</u> below and click appropriate search.</i><br>
<input type="text" name="StrUserid" size="20">
<input id=idsearchbutton class="button" type="button" value="Search On UserID" name="userid" onClick="SearchScope">
</td>
</tr>
<tr>
<td valign="top" height="300" bgcolor="#000080">
<Div id="BaseUserInfo"></Div>
<br>
<table border="0" width="100%" cellspacing="1" cellpadding="0">
<tr>
<td width="60%" valign="top"><Div id="AddUserInfo"></Div></td>
<td width="40%" valign="top"><Div id="AccUserStatus"></Div></td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" height="70" bgcolor="#000080">
<div id="AdditionalOptions"></div>
</td>
</tr>
</table>
如果这是为您的第一个HTA应用体验,那么您的目标太高了。简单地简化了您的按钮弹出" Hello World"消息,然后详细说明。使消息包括从免费文本字段中撤出的内容,逐渐构建。
现在应该有效: - (
<html>
<head>
<hta:application
applicationname="ADUCUserGrab"
border="thin"
borderstyle="normal"
caption="ADUC User Grab"
contextmenu="yes"
icon="aduc_sm.ico"
maximizebutton="no"
minimizebutton="yes"
navigable="yes"
scroll="yes"
selection="yes"
showintaskbar="yes"
singleinstance="yes"
sysmenu="yes"
version="1.0"
windowstate="normal"
>
</head>
<body topmargin="1" leftmargin="0" rightmargin="0" bottommargin="1" bgcolor="#000080" text="#FFFFFF">
<script language="javascript">
var adStateOpen = 1;
var ADS_SCOPE_SUBTREE = 2;
function SearchScope () {
var e;
try {
var objConnection = new ActiveXObject( "ADODB.Connection" );
objConnection.Provider = "ADsDSOObject";
//objConnection.Properties( "User ID" ) = credUser;
//objConnection.Properties( "Password" ) = credPwd;
//objConnection.Properties( "Encrypt Password" ) = true;
objConnection.Open( );
if ( objConnection.State == adStateOpen ) {
var objCommand = new ActiveXObject( "ADODB.Command" );
objCommand.ActiveConnection = objConnection;
//objCommand.Properties( "Page Size" ) = 1000;
objCommand.Properties( "Searchscope" ) = ADS_SCOPE_SUBTREE;
objCommand.CommandText = (
"SELECT "
+ "CN, distinguishedName, sAMAccountName, description, userAccountControl"
+ " FROM "
+ "'LDAP://dc=NESTLE,dc=com'"
+ " WHERE "
+ "objectCategory='user'"
+ " AND ("
+ "sAMAccountName='" + document.getElementById( "StrUserid" ).value + "'"
+ " OR "
+ "displayname LIKE '%" + document.getElementById( "StrUserid" ).value + "%'"
+ ")"
);
var objRecordSet = objCommand.Execute( );
if ( !objRecordSet.EOF ) {
alert( objRecordSet.Fields("CN").Value );
}
}
} catch (e) {
// log error
alert( e.description );
}
}
</script>
<table border="0" width="640" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="top" height="110" bgcolor="#000080">
<i>Enter the <u>userid</u> or <u>last name</u> below and click appropriate search.</i><br>
<input type="text" id="StrUserid" name="StrUserid" size="20">
<input id=idsearchbutton class="button" type="button" value="Search On UserID" onClick="SearchScope()">
</td>
</tr>
<tr>
<td valign="top" height="300" bgcolor="#000080">
<Div id="BaseUserInfo"></Div>
<br>
<table border="0" width="100%" cellspacing="1" cellpadding="0">
<tr>
<td width="60%" valign="top"><Div id="AddUserInfo"></Div></td>
<td width="40%" valign="top"><Div id="AccUserStatus"></Div></td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" height="70" bgcolor="#000080">
<div id="AdditionalOptions"></div>
</td>
</tr>
</table>
</body>
</html>