SoftwareEngineering/ProgramLanguage/WSH/VBScript
<html language="ja">
<head>
<title>User Object プロパティ</title>
<HTA:APPLICATION ID="sample"
APPLICATIONNAME="HTA"
BORDER="thick"
BORDERSTYLE="normal"
CAPTION="yes"
ICON=""
INNERBORDER="no"
MAXIMIZEBUTTON="yes"
MINIMIZEBUTTON="yes"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
VERSION="1.0"
WINDOWSTATE="normal"
SCROLL="yes"
SCROLLFLAT="yes"
SELECTION="yes"
CONTEXTMENU="yes"
NAVIGABLE="yes"
/>
<script language="VBScript">
<!--
Const ADS_SECURE_AUTHENTICATION = 1
Const ADS_USE_ENCRYPTION = 2
Function GetAdspathOfUserObject(ldapPath, userName)
GetAdspathOfUserObject = ""
Set connection = CreateObject("ADODB.Connection")
Set command = CreateObject("ADODB.Command")
connection.Provider = "ADsDSOObject"
connection.Properties("User ID") = txtUserID.value
connection.Properties("password") = txtPassword.value
connection.Open "Active Directory Provider"
Set command.ActiveConnection = connection
command.CommandText = "select name, cn, adspath, distinguishedName " _
& "from " & "'" & ldapPath & "' " _
& "WHERE objectCategory='User' AND objectClass = 'user' AND name='" & userName & "' "
Set resultSet = command.Execute
If (Not resultSet.EOF) Then
adspath = resultSet.Fields("adspath")
End If
resultSet.Clone
Set resultSet = Nothing
Set command = Nothing
Set connection = Nothing
GetAdspathOfUserObject = adspath
End Function
Function FormatPropertyValue(name, value)
If (IsArray(value)) Then
FormatPropertyValue = name & ":[" & Join(value, "|") & "]<br>"
Else
FormatPropertyValue = name & ":[" & value & "]<br>"
End If
End Function
Function btnExecute_Click()
layerInfoArea.innerHTML = ""
adspath = GetAdspathOfUserObject(txtLdapPath.value, txtAccountName.value)
If (adspath = "") Then
layerInfoArea.innerHTML = "アカウントが存在しません"
Exit Function
End If
Set ldap = GetObject("LDAP:")
Set user = ldap.OpenDSObject(adspath, txtUserID.value, txtPassword.value, ADS_USE_ENCRYPTION And ADS_SECURE_AUTHENTICATION)
text = ""
text = text & FormatPropertyValue("アカウント名", user.cn)
text = text & FormatPropertyValue("姓", user.sn)
text = text & FormatPropertyValue("名", user.givenName)
text = text & FormatPropertyValue("イニシャル", user.Initials)
text = text & FormatPropertyValue("説明", user.description)
If (user.AccountExpirationDate <= "1970/01/01") Then
text = text & FormatPropertyValue("アカウント期限", "無期限")
Else
text = text & FormatPropertyValue("アカウント期限", user.AccountExpirationDate)
End If
text = text & FormatPropertyValue("ログオンスクリプト", user.ScriptPath)
text = text & FormatPropertyValue("国/地域(コード)", user.c)
text = text & FormatPropertyValue("国/地域(表示名)", user.co)
text = text & FormatPropertyValue("郵便番号", user.postalCode)
text = text & FormatPropertyValue("都道府県", user.st)
text = text & FormatPropertyValue("市区町村", user.l)
text = text & FormatPropertyValue("番地", user.streetAddress)
text = text & FormatPropertyValue("会社名", user.company)
text = text & FormatPropertyValue("部署", user.department)
text = text & FormatPropertyValue("役職", user.title)
text = text & FormatPropertyValue("上司", user.manager)
text = text & FormatPropertyValue("秘書", user.msExchAssistantName)
text = text & FormatPropertyValue("事業所", user.physicalDeliveryOfficeName)
text = text & FormatPropertyValue("電話番号(FAX)", user.facsimileTelephoneNumber)
text = text & FormatPropertyValue("電話番号(携帯電話)", user.mobile)
text = text & FormatPropertyValue("電話番号(ポケットベル)", user.pager)
text = text & FormatPropertyValue("電話番号", user.telephoneNumber)
text = text & FormatPropertyValue("電話番号(自宅)", user.homePhone)
text = text & FormatPropertyValue("電話番号(IP電話)", user.ipPhone)
text = text & FormatPropertyValue("私書箱", user.postOfficeBox)
text = text & FormatPropertyValue("Web ページ", user.wWWHomePage)
text = text & FormatPropertyValue("電子メール", user.mail)
text = text & FormatPropertyValue("プロキシアドレス", user.ProxyAddresses)
text = text & FormatPropertyValue("表示名", user.displayName)
text = text & FormatPropertyValue("会社名(フリガナ)", user.[msDS-PhoneticCompanyName])
text = text & FormatPropertyValue("部署(フリガナ)", user.[msDS-PhoneticDepartment])
text = text & FormatPropertyValue("表示名(フリガナ)", user.[msDS-PhoneticDisplayName])
text = text & FormatPropertyValue("名(フリガナ)", user.[msDS-PhoneticFirstName])
text = text & FormatPropertyValue("姓(フリガナ)", user.[msDS-PhoneticLastName])
text = text & FormatPropertyValue("カスタム属性1", user.ExtensionAttribute1)
text = text & FormatPropertyValue("カスタム属性6", user.ExtensionAttribute6)
text = text & FormatPropertyValue("カスタム属性7", user.ExtensionAttribute7)
text = text & FormatPropertyValue("カスタム属性8", user.ExtensionAttribute8)
text = text & FormatPropertyValue("カスタム属性9", user.ExtensionAttribute9)
text = text & FormatPropertyValue("カスタム属性10", user.ExtensionAttribute10)
text = text & FormatPropertyValue("カスタム属性11", user.ExtensionAttribute11)
text = text & FormatPropertyValue("カスタム属性13", user.ExtensionAttribute13)
text = text & FormatPropertyValue("ログオン先", user.UserWorkstations)
text = text & FormatPropertyValue("配信制限", user.authOrig)
text = text & "DN:[" & user.DistinguishedName & "]<br>"
text = text & FormatPropertyValue("所属するグループ", user.memberOf)
If (user.homeMDB <> "") Then
text = text & FormatPropertyValue("メールボックスの有無", "有")
Else
text = text & FormatPropertyValue("メールボックスの有無", "無")
End If
If (user.msExchHideFromAddressLists = true) Then
text = text & FormatPropertyValue("Exchange アドレス帳一覧への表示有無", "無")
Else
text = text & FormatPropertyValue("Exchange アドレス帳一覧への表示有無", "有")
End If
layerInfoArea.innerHTML = text
End Function
-->
</script>
</head>
<body>
<table>
<tr>
<td>検索パス</td><td>:<input id="txtLdapPath" size="100" value="LDAP://computer_name.codereign.org/DC=codereign,DC=org"></td>
</tr>
<tr>
<td>ユーザー名</td><td>:<input id="txtUserID" value="AZZGAMSSv"></td>
</tr>
<tr>
<td>パスワード</td><td>:<input id="txtPassword" value="2wsxcde3#"></td>
</tr>
</table>
<hr>
検索するアカウント名:<input id="txtAccountName" type="text" value="common_name" >
<input id="btnExecute" type="button" value="実行" onclick="btnExecute_Click()"><br>
<hr>
<div id="layerInfoArea"></div>
</body>
</html>