Novell is now a part of Micro Focus

Generate Web Page with list of Current NCP Servers in the Tree

Novell Cool Solutions: Tip
By Stuart Beckett

Digg This - Slashdot This

Posted: 16 Mar 2006


Generating a listing of current NCP servers in the tree on a web page listing name, version and a link to each server's NRM page.


We have setup an AMP environment on the virtual server that also servers our iFolder. In this Apache server we have a section just for the IS department. The code below will query LDAP for all NCP Servers, sort the list, then generate a table with the name, version, link to the NRM, and if the server has an HP ILO card a link to that as well. If the server is a virtual server (from the cluster) it is not listed.

This page has saved everyone in the IS Dept to easily connect to the servers to manage them.


<!DOCTYPE html 
	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	" ">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " ">
<html xmlns="" xml:lang="en" lang="en">
		<title>Server List</title>
		<?php include('head.incl'); ?>

		<div id="all">

			<div id="header">
			</div><!-- close header -->

			<div id="header2">
				<?php include('nrm/header.incl'); ?>
			</div><!-- close header2 -->

			<div id="headermenu">
				<?php include('mainmenu.incl'); ?>
			</div><!-- close headermenu -->

			<div id="onecolumn">
		<?php		// This php section is for defining variables and connecting to the LDAP server

			//These are the variables defined to pull the information
			$ldapserver = "";	// must be a valid LDAP server!
			$dn = "o=Fishel";	// context where the LDAP search starts

			//This establishes a connection to a LDAP server on a specified hostname and port.
			$ldap = ldap_connect($ldapserver);

			//This does a bind operation on the directory in anonymous mode
			$bind_results = ldap_bind($ldap);

            //This is the current list of non-ilo capable servers
            $nonilo = array('CORPBACKUP','CORPBM','CORPPROXY','CORP_MAIL','CORP_WEB','CORPZEN','CORP_2');

A listing of the sites and the servers.

		<?php		// This php section actually pulls data out of LDAP

			//These are the variables defined to pull the information for the body
			$filter = "objectclass=ncpserver";			// the filter specification for the LDAP search uses the ID variable passed to the document
			$attrlist = array("cn", "version");

			//This section will pull the values for the object
			$results = ldap_search($ldap, $dn, $filter, $attrlist);

            // sort entries by last name ('cn')
            ldap_sort ( $ldap, $results, 'cn' ) ;

			$info = ldap_get_entries($ldap, $results);


printf( "<table cellspacing=0>\n" );

printf( "<tr><td><b>Server Name</b></td><td>  </td><td><b>Software Version</b></td><td>  </td><td><b>Link to NRM</b></td><td>  </td><td><b>Link to ILO</b></td></tr>\n" );

  for ($item = 0; $item < $info['count']; $item++) {

    if ($info[$item]['version'][0] != "NWCS[DS]") {  // if the item is not a cluster resource then print, else increment

        // check for even or odd
        if ($itemtwo/2 == round($itemtwo/2)) {
            $c = "class=\"even\"";  // class 'even' changes the background color to light gray
        } else {
            $c = "";
        // check to see if it is a non-ilo server see array $nonilo above
        $ilovalue = 0;
     foreach ( $nonilo as $value ) {
        if ( $info[$item]['cn'][0] == $value ) {
            $ilovalue = 1;

        printf( "<tr %s>", $c );
        printf( "<td>%s</td><td></td><td>%s</td><td></td><td>", $info[$item]['cn'][0], $info[$item]['version'][0] );
        printf( "<a target=\"_blank\" href=>%s</a>", ereg_replace("_","-",$info[$item]['cn'][0]), $info[$item]['cn'][0] );
        printf( "</td><td></td><td>" );
        if ($ilovalue == 0) {
            printf( "<a target=\"_blank\" href=>%s-ILO</a>", $info[$item]['cn'][0], $info[$item]['cn'][0] );
        printf( "</td></tr>\n" );

printf( "</table>\n" );



			</div><!-- close onecolumn -->

			<div id="lastrevised">
				<?php include('lastrevised.incl'); ?>
			</div><!-- close lastrevised -->

		</div><!-- close all -->



NW 6.5 sp 4a

Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions.

© Copyright Micro Focus or one of its affiliates