サーバの移設に伴い、このサイトは下記URLへ移設しました。
http://wp.kaz.bz/tech/
今後は新しい記事はそちらにのみアップします。

2009/11/05 木曜日 10:28:49

[ VBA/ASPなど ][ Windows ]新ページ[2009/11/05] | ActiveDirectoryアカウントロック解除スクリプト。


' ActiveDirectoryドメイン名
Const DOMAIN_NAME = "dohouse.local"
' ロックアウト解除メイン
Function unlock_account(strAccount)
Dim tmpRet

Dim objUser
Dim strDomain

On Error Resume Next
Set objUser = GetObject("WinNT://" & DOMAIN_NAME & "/" & strAccount & ",user")
objUser.IsAccountLocked = False
objUser.SetInfo

If Len(Err.Description) > 0 Then
tmpRet = "Error:" & Err.Description
Else
tmpRet = "完了"
End If
Set objUser = Nothing
On Error Goto 0
unlock_account = tmpRet
End Function
' ユーザ入力画面表示
Sub Main()
Dim strUser
strUser = inputbox("ロック解除するユーザ名(例:suena1)")

If strUser = "" Then
msgbox "処理を中止しました。"
Else
msgbox unlock_account(strUser)
End If
End Sub
Main