File: ldap_entry.inc

package info (click to toggle)
openldap2 2.0.23-6.3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 7,816 kB
  • ctags: 6,366
  • sloc: ansic: 86,391; sh: 9,816; makefile: 1,270; cpp: 1,107; sql: 838; php: 700; perl: 134; tcl: 40
file content (105 lines) | stat: -rw-r--r-- 3,089 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
<?
include 'include/ldap_entry_attribute.inc';
class ldap_entry {
	var $attributes;
	var $dn;
	var $parent;
	var $attributeCount;
	var $link_identifier;
	var $r_e_i;

	cfunction ldap_entry($l_i) {
	//	echo "creating new ldap_entry<br>\n";
		$this->link_identifier = $l_i;
	}

	cfunction getAttributes() {
		$i=0;
		$attrib = new ldap_entry_attribute($this->dn);
		$n = ldap_first_attribute($this->link_identifier, $this->r_e_i, &$ber);
		while ($n) {
			$attrib->name = $n;
			$attrib->getValues($this->link_identifier,$this->r_e_i);
			$this->attributes[$i] = $attrib;
			$i++;
			$attrib = new ldap_entry_attribute($this->dn);
			$n = ldap_next_attribute($this->link_identifier, $this->r_e_i, $ber);
		}
	}

	cfunction formatHTMLDN($dn) {
		global $FILE, $host;
		$string = "";
		$attribs = ldap_explode_dn($dn, 0);
		$names = ldap_explode_dn($dn, 1);
		for ($i=0; $i<$attribs["count"]; $i++) {
			$s = $attribs[$i];
			for ($j=$i+1; $j<$attribs["count"]; $j++) {
				$s .= ",".$attribs[$j];
			}
			if (($s[0] == "c") && ($s[1] == "n")) {
				$string .= "<a href=".$FILE."?ldap_action=read&base_dn=".urlencode($s).">".$names[$i]."</a>";
			}
			else {
				$string .= "<a href=".$FILE."?ldap_action=list&base_dn=".urlencode($s).">".$names[$i]."</a>";
			}
			if ($i<$attribs["count"]-1) { $string .= ", "; }
		}
		return $string;
	}

	cfunction formatHTMLAttributes() {
		global $FILE, $host;
		$s = "";
		$s .= "<tr>\n\t";
		$s .= '<td colspan=2 bgcolor="#9380DB" align="center" valign="middle">';
		$s .= "\n\t\t<h3 class=head>".$this->formatHTMLDN($this->dn)."</h3>\n";
		$s .= "\t\t</td>\n\t</tr>\n";	
		$c = count($this->attributes);
		for ($i=0; $i<$c; $i++) {
			$attrib = $this->attributes[$i];
			if ($attrib->isVisible($attrib->name) == "TRUE") {
				$s .= $attrib->formatHTMLValues();
			}
		}
		$a = $this->attributes[0];
		$v = $a->values[1];
		if ($v == "organizationalUnit" || $v == "organization") {
			$s .= "<tr>\n\t<td colspan=2>\n";
			$s .= "\t\t<a href=".$FILE."?host=".urlencode($host)."&ldap_action=list&base_dn=".urlencode($this->dn).">Browse</a>\n";
			$s .= "\t\t</td>\n\t</tr>\n";
		}
		else if ($v == "person") {
			$s .= "<tr>\n\t<td colspan=2>\n";
			$s .= "\t\t<a href=".$FILE."?host=".urlencode($host)."&ldap_action=read&admin_action=modify&base_dn=".urlencode($this->dn).">Modify</a>\n";
			$s .= "\t\t</td>\n\t</tr>\n";
		}
		else {
			$s .= "<tr>\n\t<td colspan=2>\n\t\t&nbsp;\n\t\t</td>\n\t</tr>\n";
		}
		return $s;
	}

	cfunction display() {
		global $FILE, $host;
		echo "<tr><td colspan=2 bgcolor=gray>";
		echo "<h3>".ldap_dn2ufn($this->dn)."</h3>";
		echo "</td></tr>";
		$c = count($this->attributes);
		for ($i=0; $i<$c; $i++) {
			$attrib = $this->attributes[$i];
			$attrib->display();
		}
		$a = $this->attributes[0];
		$v = $a->values[1];
		if ($v == "organizationalUnit" || $v == "organization") {
			echo "<tr><td colspan=2>";
			echo "<a href=".$FILE."?host=".urlencode($host)."&ldap_action=list&base_dn=".urlencode($this->dn).">Browse</a>";
			echo "</td></tr>";
		}
		else {
			echo "<tr><td colspan=2>&nbsp;</td></tr>";
		}
	}
}
?>