steffen: server/perl-kolab/Kolab-LDAP LDAP.pm,1.27,1.28

cvs at intevation.de cvs at intevation.de
Fri Apr 22 03:37:18 CEST 2005


Author: steffen

Update of /kolabrepository/server/perl-kolab/Kolab-LDAP
In directory doto:/tmp/cvs-serv27831/Kolab-LDAP

Modified Files:
	LDAP.pm 
Log Message:
new feature Issue721

Index: LDAP.pm
===================================================================
RCS file: /kolabrepository/server/perl-kolab/Kolab-LDAP/LDAP.pm,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- LDAP.pm	23 Mar 2005 11:53:21 -0000	1.27
+++ LDAP.pm	22 Apr 2005 01:37:16 -0000	1.28
@@ -1,9 +1,11 @@
 package Kolab::LDAP;
 
 ##
+##  Copyright (c) 2005  Klaralvdalens Datakonsult AB
 ##  Copyright (c) 2003  Code Fusion cc
 ##
-##    Writen by Stuart Bing?<s.binge at codefusion.co.za>
+##    Writen by Stuart Bingë <s.binge at codefusion.co.za>
+##              Steffen Hansen <steffen at klaralvdalens-datakonsult.se>
 ##
 ##  This  program is free  software; you can redistribute  it and/or
 ##  modify it  under the terms of the GNU  General Public License as
@@ -380,12 +382,50 @@
 	  return 0;
 	}
 	if( lc ($Kolab::config{'is_master'}) eq 'true' && ref($del) eq 'ARRAY' && scalar(@$del) == 1 ) {
-	  # Ok we are the last one and the master
-	  Kolab::log('L', "Removing DN `$dn'");
-	  my $mesg = $masterldap->delete($dn);
-	  if ($mesg && $mesg->code ) {
-	    Kolab::log('L', "Unable to remove DN `$dn': ".$mesg->error, KOLAB_WARN);
-	  }
+	    # Ok we are the last one and the master
+	    if( $Kolab::config{'kolab_remove_objectclass'} ) {
+		# Remove the kolab-related objectClasses
+		# Some people find it useful to integrate Kolab 
+		# with an existing LDAP database and when a Kolab
+		# object is to be deleted, it should just remove
+		# the Kolab stuff and leave the rest of the object
+		# in the database.
+		#
+		# This is what we do here. 
+		# Warning: All attributes in the kolab-related 
+		# objectclasses will be deleted!
+		#
+		# PENDING(steffen): Only remove attributes that _have_ to
+		# be removed.
+		Kolab::log('L', "Removing Kolab objectClasses from DN `$dn'");
+		my $schema = $masterldap->schema( $dn );
+		foreach my $c qw(kolabInetOrgPerson kolabGroupOfNames) {
+		    my @may = map $_->{name}, $schema->may($c);
+		    my @must = map $_->{name}, $schema->must($c);
+		    foreach my $attr (@must, at may,split(' ',$Kolab::config{'kolab_remove_attributes'})) {
+			# Remove attributes
+			Kolab::log('L', "Removing attribute $attr", KOLAB_WARN);
+			my $mesg = $masterldap->modify( $dn,
+							delete => $attr );
+			if ($mesg && $mesg->code ) {
+			    Kolab::log('L', "Unable to remove attribute $attr from DN `$dn': ".$mesg->error, KOLAB_WARN);
+			}
+		    }
+		    # Remove objectClass
+		    my $mesg = $masterldap->modify( $dn,
+						    delete => { 'objectClass' => $c } );
+		    if ($mesg && $mesg->code ) {
+			Kolab::log('L', "Unable to remove Kolab objectClas $_ from DN `$dn': ".$mesg->error, KOLAB_WARN);
+		    }
+		}
+	    } else {
+		# Default behaviour, delete the object
+		Kolab::log('L', "Removing DN `$dn'");
+		my $mesg = $masterldap->delete($dn);
+		if ($mesg && $mesg->code ) {
+		    Kolab::log('L', "Unable to remove DN `$dn': ".$mesg->error, KOLAB_WARN);
+		}
+	    }
 	} elsif( lc ($Kolab::config{'is_master'}) eq 'false' ) {
 	  # Just remove us from the kolabdeleteflag
 	  # master does not perform this step as it should 





More information about the commits mailing list