クラシックASPでアクティブディレクトリから写真を表示するには? AD にログオンし、calssic ASP ページからユーザー名電話などを照会できます。サムネイルの写真フィールドは文字列を返すだけですが、クラシック ASP で写真を表示するにはどうすればよいですか?
3829 次
4 に答える
0
したがって、私が思いついた答えは次のとおりです。 strUsername = request.querystring("req") strUserRole = request.querystring("rol")
Set objDomain = GetObject ("GC://rootDSE")
objADsPath = objDomain.Get("defaultNamingContext")
Set objDomain = Nothing
Set con = Server.CreateObject("ADODB.Connection")
con.provider ="ADsDSOObject"
con.Properties("User ID") = "XXXXXXXXXXX"
con.Properties("Password") = "XXXXXXXXXXXXXXX"
con.Properties("Encrypt Password") = False
con.open "Active Directory Provider"
Set Com = CreateObject("ADODB.Command")
Set Com.ActiveConnection = con
Com.CommandText ="select name,telephonenumber,mail,thumbnailPhoto, Department, title FROM 'GC://"+objADsPath+"' where sAMAccountname='"+strUsername+"'"
Set rs = Com.Execute
if not rs.eof then
tmpphoto=rs("thumbnailPhoto")
tmpdept=rs("Department")
tmptitle=rs("title")
name=rs("name")
telephonenumber=rs("telephonenumber")
mail=rs("mail")
NameArr = Split(name, " ")
cname = NameArr(0)
sname = NameArr(1)
rs.Close
con.Close
Set rs = Nothing
Set con = Nothing
%>
<div id="card"><img src="badge.jpg" width="100%"/>
<div id="personname"><%=cname & " " & sname%></div>
<div id="persongroup"><%=tmptitle%></div>
<div id="persondept"><%=tmpdept%></div>
<div id="personrole"><%=strUserRole%></div>
<div id="personimage">
<img src="getaduserimage.asp?req=NAME.SURNAME" width="100" height="100" frameborder="0" scrolling="no" />
</div>
<div id="logoimage"><img src="OUR_logo_white_small.png" width="100"/></div>
<%
else
cname = strUsername & " Not found"
end if
%>
<% 'getaduserimage.asp file contains:
strUsername = request.querystring("req")
Set objDomain = GetObject ("GC://rootDSE")
objADsPath = objDomain.Get("defaultNamingContext")
Set objDomain = Nothing
Set con = Server.CreateObject("ADODB.Connection")
con.provider ="ADsDSOObject"
con.Properties("User ID") = "xxxxxx"
con.Properties("Password") = "xxxxxxxx"
con.Properties("Encrypt Password") = False
con.open "Active Directory Provider"
Set Com = CreateObject("ADODB.Command")
Set Com.ActiveConnection = con
Com.CommandText ="select thumbnailPhoto FROM 'GC://"+objADsPath+"' where sAMAccountname='"+strUsername+"'"
Set rs = Com.Execute
Response.Expires = 0
Response.Buffer = TRUE
Response.Clear
Response.ContentType = "image/jpeg"
'#### Assuming your images are jpegs
if not rs.eof then
Response.BinaryWrite rs("thumbnailPhoto")
else
response.write "image for " & strUsername & " Not found"
end if
rs.Close
con.Close
Set rs = Nothing
Set con = Nothing
%>
于 2012-07-10T10:22:33.097 に答える
0
私があなたの質問を正しく理解していれば、画像ファイルをバイナリで取得し、画像のデータを返すときにFileSystemObject
使用response.contenttype = "image/jpeg"
して、コンテンツを画像としてレンダリングします。
于 2012-07-06T16:45:19.750 に答える
0
htmlのimgタグを使えばできます。例えば:
<img src="<%=myPhotoUrl%>">
asp コード ブロックでは、次のように宣言する必要があります。
<%
Response.Write "<img src=""" & myPhotoUrl & """>"
%>
于 2012-07-08T07:12:19.787 に答える
0
于 2012-07-06T17:09:49.497 に答える