# HG changeset patch # User Mahlon E. Smith # Date 1315351362 25200 # Node ID 12f279ef4f9d03b12dffc30eb96cde1fdd456bbe # Parent 7a8855e7cfb807f489b5b02cdf07e6e0c884f319 Backout the additional objectClasses patch for mkdir: same behavior can be acheived with 'touch', less complex to leave it as is. diff -r 7a8855e7cfb8 -r 12f279ef4f9d shelldap --- a/shelldap Tue Sep 06 16:10:33 2011 -0700 +++ b/shelldap Tue Sep 06 16:22:42 2011 -0700 @@ -311,16 +311,10 @@ =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 @@ { 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 - $dir = $self->path_to_dn( $dir ); + # normalize name, if it is not yet a legal DN + $dir = 'ou=' . $dir unless canonical_dn( $dir ); - # normalize name, if it is not yet a legal DN - $dir = 'ou='.$dir if (!canonical_dn($dir)); + # convert given path to full DN + $dir = $self->path_to_dn( $dir ); # get RDN: naming attributes (lower-case) and their values - my %rdn = %{ shift(@{ ldap_explode_dn($dir, casefold => 'lower') }) }; - - # without RDN, return error - unless ( %rdn ) { - print "Illegal DN: $dir\n"; - return; - } + my %rdn = %{ shift(@{ ldap_explode_dn($dir, casefold => 'lower') }) }; - # 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 );