File: server_info.php

package info (click to toggle)
phpldapadmin 0.9.5-3sarge3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,052 kB
  • ctags: 2,526
  • sloc: php: 21,258; sh: 262; makefile: 132; xml: 42
file content (121 lines) | stat: -rw-r--r-- 3,475 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/server_info.php,v 1.15 2004/10/24 23:51:49 uugdave Exp $
 

/* 
 * server_info.php
 * Fetches and displays all information that it can from the specified server
 * 
 * Variables that come in as GET vars:
 *  - server_id
 */
 
require './common.php';

// The attributes we'll examine when searching the LDAP server's RootDSE
$root_dse_attributes = array( 	'namingContexts', 
				'subschemaSubentry', 
				'altServer',
				'supportedExtension',
				'supportedControl',
				'supportedSASLMechanisms',
				'supportedLDAPVersion',
				'currentTime',
				'dsServiceName',
				'defaultNamingContext',
				'schemaNamingContext',
				'configurationNamingContext',
				'rootDomainNamingContext',
				'supportedLDAPPolicies',
				'highestCommittedUSN',
				'dnsHostName',
				'ldapServiceName',
				'serverName',
				'supportedCapabilities',
				'changeLog',
                'tlsAvailableCipherSuites',
                'tlsImplementationVersion',
                'supportedSASLMechanisms',
                'dsaVersion',
                'myAccessPoint',
                'dseType',
				'+',
                '*'
                );

$server_id = $_GET['server_id'];
$server_name = $servers[$server_id]['name'];

$ds = pla_ldap_connect( $server_id );
pla_ldap_connection_is_error( $ds );

// Fetch basic RootDSE attributes using the + and *. 
$r = @ldap_read( $ds, '', 'objectClass=*', array( '+', '*' ) );
if( ! $r )
	pla_error( $lang['could_not_fetch_server_info'], ldap_error( $ds ), ldap_errno( $ds )  );
$entry = @ldap_first_entry( $ds, $r );
if( ! $entry )
	pla_error( $lang['could_not_fetch_server_info'], ldap_error( $ds ), ldap_errno( $ds )  );
$attrs = @ldap_get_attributes( $ds, $entry );
$count = @ldap_count_entries( $ds, $r );

// After fetching the "basic" attributes from the RootDSE, try fetching the 
// more advanced ones (from ths list). Add them to the list of attrs to display
// if they weren't already fetched. (this was added as a work-around for OpenLDAP 
// on RHEL 3.
$r2 = @ldap_read( $ds, '', 'objectClass=*', $root_dse_attributes );
if( $r2 ) {
    $entry2 = @ldap_first_entry( $ds, $r );
    $attrs2 = @ldap_get_attributes( $ds, $entry );
    for( $i=0; $i<$attrs2['count']; $i++ ) {
            $attr = $attrs2[$i];
        if( ! isset( $attrs[ $attr ] ) ) {
            $attrs[ $attr ] = $attrs2[ $attr ];
            $attrs[ 'count' ]++;
            $attrs[] = $attr;
        }
    }
}
unset( $attrs2, $entry, $entry2 );

include './header.php';
?>

<body>
<h3 class="title"><?php echo $lang['server_info_for'] . htmlspecialchars( $server_name ); ?></h3>
<h3 class="subtitle"><?php echo $lang['server_reports_following']; ?></h3>

<?php if( $count == 0 || $attrs['count'] == 0 ) { ?>

	<br /><br /><center><?php echo $lang['nothing_to_report']; ?></center>
	<?php exit; ?>

<?php } ?>

<table class="edit_dn">
<?php
for( $i=0; $i<$attrs['count']; $i++ ) {
	$attr = $attrs[$i];
	$schema_href = "schema.php?server_id=$server_id&amp;view=attributes&amp;viewvalue=$attr";
	?>

	<tr>
		<td class="attr">
			<b>
			<a title="<?php echo sprintf( $lang['attr_name_tooltip'], $attr ); ?>" 
			   href="<?php echo $schema_href; ?>"><?php echo htmlspecialchars( $attr ); ?></a>
			</b>
		</td>
    </tr>
    <tr>
		<td class="val">
		<?php for( $j=0; $j<$attrs[ $attr ][ 'count' ]; $j++ )
			echo htmlspecialchars( $attrs[ $attr ][ $j ] ) . "<br />\n"; ?>
		</td>
    </tr>
		
<?php } ?>

</table>
</body>
</html>