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
52
shelldap
52
shelldap
|
|
@ -311,16 +311,10 @@ types. You can additionally specify your own mappings in your
|
||||||
|
|
||||||
=item B<mkdir>
|
=item B<mkdir>
|
||||||
|
|
||||||
Creates a new entry. The type of object created depends on
|
Creates a new 'organizationalUnit' entry.
|
||||||
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
|
|
||||||
|
|
||||||
mkdir myNewOrgUnit
|
mkdir containername
|
||||||
mkdir o=myNewOrg
|
mkdir ou=whatever
|
||||||
|
|
||||||
=item B<move>
|
=item B<move>
|
||||||
|
|
||||||
|
|
@ -1576,47 +1570,25 @@ sub run_mkdir
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $dir = join ' ', @_;
|
my $dir = join ' ', @_;
|
||||||
my %ClassMap = ( c => 'country',
|
|
||||||
o => 'organization',
|
|
||||||
ou => 'organizationalUnit' );
|
|
||||||
my %class;
|
|
||||||
|
|
||||||
unless ( $dir ) {
|
unless ( $dir ) {
|
||||||
print "No 'directory' provided.\n";
|
print "No 'directory' provided.\n";
|
||||||
return;
|
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 );
|
$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
|
# 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
|
# add
|
||||||
unless ( %rdn ) {
|
my $r = $self->ldap()->add( $dir, attr => [
|
||||||
print "Illegal DN: $dir\n";
|
objectClass => [ 'top', 'organizationalUnit' ], %rdn
|
||||||
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 ]);
|
|
||||||
|
|
||||||
print $r->error(), "\n";
|
print $r->error(), "\n";
|
||||||
$self->update_entries( clearcache => 1 );
|
$self->update_entries( clearcache => 1 );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue