-
Sep 7th, 2017, 07:19 AM
#1
Thread Starter
New Member
List users telephone number from AD - HELP
I have multiple variables and problems with empty cell in HTML. I'm trying to list users from AD and their mobile phones and other attributes. Because not every user has his mobile phone or mail address I have empty cells. Idea is to list each user in OU (display OU) and their attributes.
HTML Code:
<img src="Fortium_logo.jpg" alt="IIS" width="200" height="150"> <!--Početna slika-->
<%@ Language=VBScript %>
<% response.Buffer = True %>
<html><head>
<title>Imenik</title> <!--Naziv Taba-->
</head>
<body>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250"> <!--Dodavanje ČŽŠ znakova -->
<style>
table {
width:100%;
}
table, tb, td {
empty-cells: hide; <!--prazno polje -->
}
table, tb, td {
border: 1px solid black;
border-collapse: collapse; <!--kućice -->
}
th, td {
padding: 5px;
text-align: left;
}
table tr:nth-child(even) {
background-color: #bbb; <!--Boja Siva-->
}
table tr:nth-child(odd) {
background-color: #FFAF4F; <!--Boja Narančasta-->
}
table th {
background-color: black;
color: white; <!--Boja zaglavlje-->
}
</style>
<h1 style="background-color:rgb(3,219,255)">Fortium Info</h1>
<table style="width:100%">
<tr>
<th>Ime i prezime</th>
<th>Mobitel</th>
<th>Telefon</th>
<th>Kratki</th>
<th>Email</th>
</tr>
<%
' Define the AD OU that contains our users
usersOU = "LDAP://OU=Korisnici,DC=fortium,DC=local"
' Make AD connection and run query
Set objCon = Server.CreateObject("ADODB.Connection")
objCon.provider ="ADsDSOObject"
objCon.Properties("User ID") = "fortium\user"
objCon.Properties("Password") = "****"
objCon.Properties("Encrypt Password") = TRUE
objCon.open "Active Directory Provider"
Set objCom = CreateObject("ADODB.Command")
Set objCom.ActiveConnection = objCon
objCom.CommandText ="select displayName,mobile,homePhone,pager,mail FROM '"+ usersOU +"' where sAMAccountname='*' ORDER by sAMAccountname" <!--+ usersOU +"' where sAMAccountname='*' ORDER by sAMAccountname"-->
Set objRS = objCom.Execute
' Loop over returned recordset and output HTML
Response.Write "<table>" + vbCrLf
Do Until objRS.EOF
Response.Write "<tr>"
Response.Write "<td>" + objRS("displayName") + "</td>"
Response.Write "<td>" + objRS("mobile") + "</td>"
Response.Write "<td>" + objRS("homePhone") + "</td>"
Response.Write "<td>" + objRS("pager") + "</td>"
Response.Write "<td>" + objRS("mail") + "</td>"
Response.Write "</tr>" + vbCrLf
objRS.MoveNext
Response.Buffer = true <!--Response.Flush-->
Loop
Response.Write "</table>"
' Clean up
objRS.Close
objCon.Close
Set objRS = Nothing
Set objCon = Nothing
Set objCom = Nothing
%>
</body>
</html>
Last edited by dcajko; Sep 7th, 2017 at 12:21 PM.
-
Sep 7th, 2017, 01:07 PM
#2
Re: List users telephone number from AD - HELP
Compare if the returned value is either Null or an empty String, if it is then concatenate something indicating that the value does not exist (like N/A or Null).
-
Sep 8th, 2017, 03:41 AM
#3
Thread Starter
New Member
Re: List users telephone number from AD - HELP
I try with function, but result is the same...
Do Until objRS.EOF
Response.Write "<tr>"
Response.Write "<td>" + objRS("displayName") + "</td>"
Response.Write "<td> " + objRS("mobile") + " </td>"
Response.Write "<td> " + objRS("homePhone") + " </td>"
Response.Write "<td> " + objRS("pager") + " </td>"
Response.Write "<td> " + objRS("mail") + " </td>"
Response.Write "</tr>" + vbCrLf
objRS.MoveNext
-
Sep 8th, 2017, 08:34 AM
#4
Re: List users telephone number from AD - HELP
Whenever you setup a breakpoint and it hits on the first Null value, is it just skipping the code?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|