Changeset 12f279ef4f9d
Legend:
- Unmodified
- Added
- Removed
-
shelldap
r37 r38 312 312 =item B<mkdir> 313 313 314 Creates a new entry. The type of object created depends on 315 the naming attribute given, and defaults to 'organizationalUnit' 316 if none is given. 317 Supported naming attributes and corresponding object classes are: 318 c - country 319 o - organization 320 ou - organizationalUnit 321 322 mkdir myNewOrgUnit 323 mkdir o=myNewOrg 314 Creates a new 'organizationalUnit' entry. 315 316 mkdir containername 317 mkdir ou=whatever 324 318 325 319 =item B<move> … … 1577 1571 my $self = shift; 1578 1572 my $dir = join ' ', @_; 1579 my %ClassMap = ( c => 'country',1580 o => 'organization',1581 ou => 'organizationalUnit' );1582 my %class;1583 1573 1584 1574 unless ( $dir ) { … … 1587 1577 } 1588 1578 1589 # convert given path to DN 1579 # normalize name, if it is not yet a legal DN 1580 $dir = 'ou=' . $dir unless canonical_dn( $dir ); 1581 1582 # convert given path to full DN 1590 1583 $dir = $self->path_to_dn( $dir ); 1591 1584 1592 # normalize name, if it is not yet a legal DN1593 $dir = 'ou='.$dir if (!canonical_dn($dir));1594 1595 1585 # get RDN: naming attributes (lower-case) and their values 1596 my %rdn = %{ shift(@{ ldap_explode_dn($dir, casefold => 'lower') }) }; 1597 1598 # without RDN, return error 1599 unless ( %rdn ) { 1600 print "Illegal DN: $dir\n"; 1601 return; 1602 } 1603 1604 # get objectclass from naming attributes 1605 foreach my $attr (keys(%rdn)) { 1606 map { $class{$ClassMap{$_}} = 1 if ($attr =~ /^\Q$_\E$/); } 1607 keys(%ClassMap); 1608 } 1609 1610 # fail if we did not get a unique objectclass 1611 unless (scalar(keys(%class)) == 1) { 1612 print "Unsupported DN: $dir\n"; 1613 return; 1614 } 1615 1616 # create the new object 1617 my $r = $self->ldap()->add($dir, 1618 attr => [ objectClass => [ 'top', keys(%class) ], 1619 %rdn ]); 1586 my %rdn = %{ shift(@{ ldap_explode_dn($dir, casefold => 'lower') }) }; 1587 1588 # add 1589 my $r = $self->ldap()->add( $dir, attr => [ 1590 objectClass => [ 'top', 'organizationalUnit' ], %rdn 1591 ]); 1620 1592 1621 1593 print $r->error(), "\n";
Note: See TracChangeset
for help on using the changeset viewer.
