Results 1 to 4 of 4

Thread: List users telephone number from AD - HELP

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2017
    Posts
    2

    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. Name:  tabela.jpg
Views: 250
Size:  19.4 KB

    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.

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,715

    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).
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2017
    Posts
    2

    Re: List users telephone number from AD - HELP

    I try with &nbsp; function, but result is the same...

    Do Until objRS.EOF
    Response.Write "<tr>"
    Response.Write "<td>" + objRS("displayName") + "</td>"
    Response.Write "<td>&nbsp;" + objRS("mobile") + "&nbsp;</td>"
    Response.Write "<td>&nbsp;" + objRS("homePhone") + "&nbsp;</td>"
    Response.Write "<td>&nbsp;" + objRS("pager") + "&nbsp;</td>"
    Response.Write "<td>&nbsp;" + objRS("mail") + "&nbsp;</td>"
    Response.Write "</tr>" + vbCrLf
    objRS.MoveNext

  4. #4
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,715

    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?
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width