Backout the additional objectClasses patch for mkdir: same behavior can
be acheived with 'touch', less complex to leave it as is. FossilOrigin-Name: 4de6f22012f712f3c26c814d9aae2eb7ca7b43e8139feceef25a9ff49d78caf2
This commit is contained in:
parent
e075e3895f
commit
1c12c172b2
1 changed files with 12 additions and 40 deletions
50
shelldap
50
shelldap
|
|
@ -311,16 +311,10 @@ types. You can additionally specify your own mappings in your
|
|||
|
||||
=item B<mkdir>
|
||||
|
||||
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<move>
|
||||
|
||||
|
|
@ -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
|
||||
$dir = $self->path_to_dn( $dir );
|
||||
|
||||
# normalize name, if it is not yet a legal DN
|
||||
$dir = 'ou='.$dir if (!canonical_dn($dir));
|
||||
$dir = 'ou=' . $dir unless 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;
|
||||
}
|
||||
|
||||
# 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 );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue