Append a trailing slash to entries that contain other entries. Thanks
to Jonathan Rozes <jonathan@laika.com> for the idea, and Michael Granger
<ged@faeriemud.org> for telling me about the hasSubordinates attribute
(that he was already using to do exactly this in the Treequel-based ruby
shell, heh!)
--- a/shelldap Mon May 17 08:18:39 2010 -0700
+++ b/shelldap Thu Jul 15 09:01:05 2010 -0700
@@ -1402,8 +1402,12 @@
$long = $flags =~ /l/;
}
- my $s = $self->search({ scope => $recurse ? 'sub' : 'one',
- vals => $long, filter => $filter });
+ my $s = $self->search({
+ scope => $recurse ? 'sub' : 'one',
+ vals => 1,
+ filter => $filter,
+ attrs => [ '*', 'hasSubordinates' ]
+ });
if ( $s->{'code'} ) {
print "$s->{'message'}\n";
return;
@@ -1419,7 +1423,7 @@
|| {
posixAccount => 'gecos',
posixGroup => 'gidNumber',
- ipHost => 'ipHostNumber',
+ ipHost => 'ipHostNumber',
}
};
@@ -1429,6 +1433,13 @@
my $dn;
foreach my $e ( sort { $a->dn() cmp $b->dn() } @{ $s->{'entries'} } ) {
$dn = $e->dn();
+
+ # if this entry is a container for other entries, append a
+ # trailing slash.
+ if ( $e->get_value('hasSubordinates') eq 'TRUE' ) {
+ $dn .= '/';
+ }
+
my $rdn = $dn;
$rdn =~ s/,$base//i;