[[SoftwareEngineering/ProgramLanguage/WSH/VBScript]]
#author("2021-11-26T08:55:36+09:00","","")
[[ソフトウェア開発>SoftwareEngineering]] / [[VBScript>VBScript]] / Active Directory / [[OutputUserProperty>./]]

 <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 = ""
                '------------------------------------------------------------------------------
                ' 全般/General
                '------------------------------------------------------------------------------
                text = text & FormatPropertyValue("姓", user.sn)
                text = text & FormatPropertyValue("名", user.givenName)
                text = text & FormatPropertyValue("イニシャル", user.Initials)
                text = text & FormatPropertyValue("表示名", user.displayName)
                text = text & FormatPropertyValue("説明", user.description)
                text = text & FormatPropertyValue("事業所", user.physicalDeliveryOfficeName)
                text = text & FormatPropertyValue("電話番号", user.telephoneNumber)
                text = text & FormatPropertyValue("電子メール", user.mail)
                text = text & FormatPropertyValue("Web ページ", user.wWWHomePage)
                
                
                
                '------------------------------------------------------------------------------
                ' 住所/Address
                '------------------------------------------------------------------------------
                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.postOfficeBox)
                text = text & FormatPropertyValue("番地", user.streetAddress)
                
                
                
                ' ------------------------------------------------------------------------------
                ' アカウント/Account
                ' ------------------------------------------------------------------------------
                text = text & FormatPropertyValue("ユーザーログオン名", user.userPrincipalName)
                text = text & FormatPropertyValue("ユーザーログオン名(Windows 2000 以前)", user.sAMAccountName)
                text = text & FormatPropertyValue("ログオン先", user.userWorkstations)
                
                
                
                '------------------------------------------------------------------------------
                ' プロファイル/Profile
                '------------------------------------------------------------------------------
                
                
                
                '------------------------------------------------------------------------------
                ' 電話/Telephones
                '------------------------------------------------------------------------------
                text = text & FormatPropertyValue("自宅", user.homePhone)
                text = text & FormatPropertyValue("ポケットベル", user.pager)
                text = text & FormatPropertyValue("携帯電話", user.mobile)
                text = text & FormatPropertyValue("FAX", user.facsimileTelephoneNumber)
                text = text & FormatPropertyValue("IP 電話", user.ipPhone)
                text = text & FormatPropertyValue("メモ", user.info)
                
                
                
                '------------------------------------------------------------------------------
                ' 組織/Organization
                '------------------------------------------------------------------------------
                text = text & FormatPropertyValue("会社名", user.company)
                text = text & FormatPropertyValue("部署", user.department)
                text = text & FormatPropertyValue("役職", user.title)
                text = text & FormatPropertyValue("上司", user.manager)
                 
                 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=""></td>
             </tr>
             <tr>
                 <td>パスワード</td><td>:<input id="txtPassword" value=""></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>

トップ   差分 履歴 リロード   一覧 検索 最終更新   ヘルプ   最終更新のRSS