From 1c12c172b2abe43d038a3a05aec4a7ec0b94fcde Mon Sep 17 00:00:00 2001 From: "mahlon@martini.nu" Date: Tue, 6 Sep 2011 23:22:41 +0000 Subject: [PATCH] Backout the additional objectClasses patch for mkdir: same behavior can be acheived with 'touch', less complex to leave it as is. FossilOrigin-Name: 4de6f22012f712f3c26c814d9aae2eb7ca7b43e8139feceef25a9ff49d78caf2 --- shelldap | 52 ++++++++++++---------------------------------------- 1 file changed, 12 insertions(+), 40 deletions(-) diff --git a/shelldap b/shelldap index 1932771..24943bd 100755 --- a/shelldap +++ b/shelldap @@ -311,16 +311,10 @@ types. You can additionally specify your own mappings in your =item B -Creates a new entry. The type of object created depends on -the naming attribute given, and defaults to 'organizationalUnit' -if none is given. -Supported naming attributes and corresponding object classes are: - c - country - o - organization - ou - organizationalUnit +Creates a new 'organizationalUnit' entry. - mkdir myNewOrgUnit - mkdir o=myNewOrg + mkdir containername + mkdir ou=whatever =item B @@ -1576,47 +1570,25 @@ sub run_mkdir { my $self = shift; my $dir = join ' ', @_; - my %ClassMap = ( c => 'country', - o => 'organization', - ou => 'organizationalUnit' ); - my %class; unless ( $dir ) { print "No 'directory' provided.\n"; return; } - # convert given path to DN + # normalize name, if it is not yet a legal DN + $dir = 'ou=' . $dir unless canonical_dn( $dir ); + + # convert given path to full DN $dir = $self->path_to_dn( $dir ); - # normalize name, if it is not yet a legal DN - $dir = 'ou='.$dir if (!canonical_dn($dir)); - # get RDN: naming attributes (lower-case) and their values - my %rdn = %{ shift(@{ ldap_explode_dn($dir, casefold => 'lower') }) }; + my %rdn = %{ shift(@{ ldap_explode_dn($dir, casefold => 'lower') }) }; - # without RDN, return error - unless ( %rdn ) { - print "Illegal DN: $dir\n"; - return; - } - - # get objectclass from naming attributes - foreach my $attr (keys(%rdn)) { - map { $class{$ClassMap{$_}} = 1 if ($attr =~ /^\Q$_\E$/); } - keys(%ClassMap); - } - - # fail if we did not get a unique objectclass - unless (scalar(keys(%class)) == 1) { - print "Unsupported DN: $dir\n"; - return; - } - - # create the new object - my $r = $self->ldap()->add($dir, - attr => [ objectClass => [ 'top', keys(%class) ], - %rdn ]); + # add + my $r = $self->ldap()->add( $dir, attr => [ + objectClass => [ 'top', 'organizationalUnit' ], %rdn + ]); print $r->error(), "\n"; $self->update_entries( clearcache => 1 );