'''函式功能:查詢域使用者資訊
'''引數說明:stradmin-域管理賬戶;password-域帳戶密碼;domain-域伺服器。
'''''' 參考資料:
''' 搜尋:query ldap for existing user classic asp 在 www.experts-exchange.com
function getaduserdata(stradmin,strpassword,domain,username)
if authenticateuser(stradmin,strpassword,domain)=false then '如果管理員認證失敗則退出此過程
response.write "認證失敗。"
exit function
end if
dim conn, strrs, rs, strconn
set conn = server.createobject("adodb.connection")
set rs = server.createobject("adodb.recordset")
conn.provider = "adsdsoobject"
conn.properties("user id") = stradmin
conn.properties("password") = strpassword
conn.properties("encrypt password") = true
strconn = "active directory provider"
conn.open strconn , stradmin, strpassword
strrs = "select name from 'ldap://" & domain & "' where samaccountname = '"&username&"' order by name "
rs.open strrs, conn,1,1
while rs.eof = false
getaduserdata=rs.fields("name")
rs.movenext
wend
end function
'''函式功能:驗證域使用者賬號密碼
'''引數說明:username-域賬戶;password-域帳戶密碼;domain-域伺服器。
'''返回: 使用者存在且賬號密碼正確則返回true,否則返回false;
''' 參考資料:
''' 搜尋:ldap + asp classic + adodb 在 stackoverflow
''' 搜尋:getting started with asp for adsi 在 微軟msdn
function authenticateuser(username, password, domain)
dim struser
' assume failure
authenticateuser = false
struser = username
strpassword = password
strquery = "select cn from 'ldap://" & domain & "' where objectclass='*' "
set oconn = server.createobject("adodb.connection")
oconn.provider = "adsdsoobject"
oconn.properties("user id") = struser
oconn.properties("password") = strpassword
oconn.properties("encrypt password") = true
oconn.open "ds query", struser, strpassword
set cmd = server.createobject("adodb.command")
set cmd.activeconnection = oconn
cmd.commandtext = strquery
on error resume next
set ors = cmd.execute
if ors.bof or ors.eof then
authenticateuser = false
else
authenticateuser = true
end if
set ors = nothing
set oconn = nothing
end function
'''呼叫:
adusername=getaduserdata("已知賬戶","已知密碼","yourdomain.com","要查詢的域賬戶")
c 獲取AD賬戶資訊
1 獲取連線語句 2 獲取相關資訊 3 搜尋資訊 3 遍歷資訊 注意 遍歷的電腦必須加入域環境 ipglobalproperties ipglobalproperties ipglobalproperties.getipglobalproperties string doname ipglobalp...
AD 檢視賬戶資訊命令 Get aduser
從ad匯出所有啟用的郵箱列表 1 get aduser filter properties select name,samaccountname,displayname,userprincipalname,surname,givenname 匯出禁用的 ad 賬戶,以日期為準進行排序 1get ad...
AD域使用者賬戶屬性對照表
使用者帳戶屬性對照表,一部分經常用到,免得到處找,列在下面參考參考 常規 標籤 姓 sn 名 givename 英文縮寫 initials 顯示名稱 displayname 描述 description 辦公室 physicaldeliveryofficename 號碼 telephonenumbe...