我正在尝试创建我的第一个应用程序。我想创建一个脚本,从Active Directory中提取一些用户的属性。我已经创建了HTA应用程序,但是它不起作用。 我真的需要你的支持。
谢谢。
这是HTML代码[适用于HTA应用
以下是脚本详细信息:
<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应用程序的] HTML代码:
$result = $expected_array = [];
foreach($array as $k=>$v){
$result[$v[0].'#'.$v[1]][] = $v[2]; //making unique key value with # for year
}
foreach($result as $key=>$value){
list($model,$trim) = explode('#',$key); // exploding with # to get model and trim
$expected_array[]= ['Model'=>$model, 'Trim'=>$trim,'Year'=>implode('-',[$value[0],$value[count($value)-1]])];
}
print_r($expected_array);
答案 0 :(得分:0)
如果这是您的首次HTA应用体验,那么您的目标就太高了。进行简化,直到您的按钮弹出“ Hello World”消息,然后进行详细说明。使消息包含从自由文本字段中提取的内容,并逐步构建。
答案 1 :(得分:0)
现在它应该可以工作了:-)
<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>