b-r-you-know
Grünschnabel
Hey und Hallo!
Nach langem hin und her habe ich mich dafür entschlossen mein Problem hier im Forum zu Posten. (Man muss dazu sagen, dass ich echt keine Ahnung mehr habe ...)
Zur Situation:
Linux Server (SUSE 11.1) auf dem alle Dienste laufen (inklusive LDAP)
Windows Workstations: auf denen via MS Outlook auf das LDAP Verzeichnis (Adressbuch) zugegriffen wird.
Stand der Dinge:
Habe nach mehrere Stunden den LDAP Server zum laufen gebracht. Und kann nun via PHP auf diesen zugreifen. Lediglich bleibt ein Problem: Ich kann mich zum Server verbinden, Anfragen stellen, sogar Einträge löschen; ABER keine neuen Einträge erstellen.
Vielleicht kann mir jmd bei diesem Problem weiterhelfen. Ich kann mir vorstellen, dass es sich nur um eine minimale Änderung in der config handeln kann.
Danke im Vorhinein
Bruno
Zum Abschluss noch der CODE:
PHP Code
SLAPD.CONF
Nach langem hin und her habe ich mich dafür entschlossen mein Problem hier im Forum zu Posten. (Man muss dazu sagen, dass ich echt keine Ahnung mehr habe ...)
Zur Situation:
Linux Server (SUSE 11.1) auf dem alle Dienste laufen (inklusive LDAP)
Windows Workstations: auf denen via MS Outlook auf das LDAP Verzeichnis (Adressbuch) zugegriffen wird.
Stand der Dinge:
Habe nach mehrere Stunden den LDAP Server zum laufen gebracht. Und kann nun via PHP auf diesen zugreifen. Lediglich bleibt ein Problem: Ich kann mich zum Server verbinden, Anfragen stellen, sogar Einträge löschen; ABER keine neuen Einträge erstellen.
Vielleicht kann mir jmd bei diesem Problem weiterhelfen. Ich kann mir vorstellen, dass es sich nur um eine minimale Änderung in der config handeln kann.
Danke im Vorhinein
Bruno
Zum Abschluss noch der CODE:
PHP Code
Code:
<?php
// IP und Host ausgeben
$ip = $_SERVER['REMOTE_ADDR'];
$host = gethostbyaddr($ip);
echo "Hostname: $host<br>";
// verwenden von ldap bind
$root_dn = 'cn=root,o=meine-firma,c=com'; // ldap rdn oder dn
$root_pw = 'secret'; // entsprechendes password
// LDAP Variablen
$ldap_server = "192.168.0.XXX"; // Ihr ldap servers
$ldap_port = 389; // Die Portnummer ihres ldap servers
$ldap_con = ldap_connect($ldap_server, $ldap_port) or die("Could not connect to server. Error is " .ldap_error($ldap_con));
if($ldap_con) {echo "connected to ldap_server ".$ldap_server." with message: ".ldap_error($ldap_con)."<br>";}
ldap_set_option($ldap_con, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ad, LDAP_OPT_REFERRALS, 0);
$ldap_bind = ldap_bind($ldap_con, $root_dn, $root_pw) or die("Could not bind to server. Error is " .ldap_error($ldap_con));
if($ldap_bind) {echo "bind to dn ".$root_dn." with message: ".ldap_error($ldap_con)."<br>";}
$base_dn = "o=meine-firma,c=com";
$attribs= array("mail");
$sr=ldap_search($ldap_con, $base_dn, "mail=pet*", $attribs);
echo "Anzahl gefundenen Einträge ".ldap_count_entries($ldap_con,$sr)."<br>";
//Einträge holen
$info = ldap_get_entries($ldap_con, $sr);
echo "Daten für ".$info["count"]." Items gefunden:<p>";
for ($i=0; $i<$info["count"]; $i++) {
echo "dn ist: ". $info[$i]["dn"] ."<br>";
echo "erster cn Eintrag: ". $info[$i]["cn"][0] ."<br>";
echo "erster email Eintrag: ". $info[$i]["mail"][0] ."<p>";
}
if (ldap_get_option($ldap_con, LDAP_OPT_PROTOCOL_VERSION, $version))
echo "Sie benutzen die Protokollversion $version<br>";
else
echo "Protokollversion konnte nicht bestimmt werden<br>";
$basis_dn = "o=meine-firma, c=com";
$nur_dieses = array("ou");
$sr=ldap_list($ldap_con, $basis_dn, "ou=*", $nur_dieses);
$info = ldap_get_entries($ldap_con, $sr);
for ($i=0; $i<$info["count"]; $i++)
echo $info[$i]["ou"][0]."<br>";
#$ldap_delete = ldap_delete($ldap_con,'cn=emueller,ou=Support,o=SPS-Technik,c=AT') or die ("Could not DELETE Entry. Error is " .ldap_error($ldap_con));
# mmuster, Development, meine-firma,com
$dn = 'cn=mmuster,ou=Sales,o=meine-firma,c=com';
$info["objectclass"][0] = 'person';
$info["objectclass"][1] = 'organizationalPerson';
$info["objectclass"][2] = 'inetOrgPerson';
$info["cn"][0] = 'mmuster';
$info["cn"][1] = 'Systemverwalter';
$info["cn"][2] = 'Max Mustermann';
$info["uid"] = 'mmuster';
$info["mail"] = 'mmuster@meine-firma.com';
$info["telephoneNumber"] = '123456789';
// hinzufügen der Daten zum Verzeichnis
$ldap_add = ldap_add($ldap_con, $dn, $info) or die ("Could not ADD Entry. Error is " .ldap_error($ldap_add));;
//never forget to unbind!
ldap_unbind($ldap_con);
?>
SLAPD.CONF
Code:
#
# See slapd.conf(5) for details on configuration options.
# This file should NOT be world readable.
#
#include /etc/openldap/schema/core.schema.SPSTechnik
include /etc/openldap/schema/core.schema
include /etc/openldap/schema/cosine.schema
include /etc/openldap/schema/inetorgperson.schema
include /etc/openldap/schema/rfc2307bis.schema
include /etc/openldap/schema/yast.schema
# Define global ACLs to disable default read access.
# Do not enable referrals until AFTER you have a working directory
# service AND an understanding of referrals.
#referral ldap://root.openldap.org
pidfile /var/run/slapd/slapd.pid
argsfile /var/run/slapd/slapd.args
allow bind_v2 bind_anon_cred
# Load dynamic backend modules:
# modulepath /usr/lib/openldap/modules
# moduleload back_bdb.la
# moduleload back_hdb.la
# moduleload back_ldap.la
# Sample security restrictions
# Require integrity protection (prevent hijacking)
# Require 112-bit (3DES or better) encryption for updates
# Require 63-bit encryption for simple bind
# security ssf=1 update_ssf=112 simple_bind=64
# Sample access control policy:
# Root DSE: allow anyone to read it
# Subschema (sub)entry DSE: allow anyone to read it
# Other DSEs:
# Allow self write access to user password
# Allow anonymous users to authenticate
# Allow read access to everything else
# Directives needed to implement policy:
# Grundlegende Zugriffsrechte
# Die Basis ist für lesbar
access to dn.base=""
by * read
# Alle düSubschema lesen
access to dn.base="cn=Subschema"
by * read
# Das Atribut userPassword darf vom jewiligen User geschrieben,
# von allen zur autentivizierung verwendet werden
access to attrs=userPassword,userPKCS12
by self write
by * auth
# Das Atribut shadowLastChange (letzer login) vom jewiligen User geschrieben,
# von allen gelesen werden.
access to attrs=shadowLastChange
by self write
by * read
# Alle Atribute duerfen vom Administrator gelesen und geschrieben werden
# hoffentlich bringt das etwas
access to *
by dn="cn=root,o=SPS-Technik,c=AT" write
by * read
access to *
by * read
access to *
by * write
# if no access controls are present, the default policy
# allows anyone and everyone to read anything but restricts
# updates to rootdn. (e.g., "access to * by * read")
#
# rootdn can always read and write EVERYTHING!
#######################################################################
# BDB database definitions
#######################################################################
database bdb
checkpoint 1024 5
cachesize 10000
suffix "o=SPS-Technik, c=AT"
directory /var/lib/ldap
rootdn "cn=root, o=SPS-Technik, c=AT"
rootpw secret
# Cleartext passwords, especially for the rootdn, should
# be avoid. See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd and slap tools.
# Mode 700 recommended.
directory /var/lib/ldap
# Indices to maintain
index objectClass eq