On Dec 6, 2006, at 8:02 AM, Eric Nichols wrote:
Excuse all of my past ramblings about schema...
Active Directory (and possibly ADAM) stores extended attribute schema
information in extendedAttributeInfo. I wrote a function which
merges this
information with attributeTypes. Each extended attribute will be
prefixed
with an 'x-' in keeping with some much needed guidance from Peter
Marschall.
The result is a merged Net::LDAP::Schema object with some important
information such as attribute length and if it is indexed etc.
Is this a hack? Absolutely.
Is extentedattributeinfo LDAP standard? Nope, But I have seen it
implemented
in Active Directory, ADAM and even seen mention of it in Lotus Notes.
My hope is that someone can carry this code on into a sub class
(Net::LDAP::Schema::Extended?). I have only tested this code in so
far as
reading attribute information. I have not played with any other
Schema
functions with this hacked object.
Eric,
Thanks for the code and sorry for the slow reply.
I personally do not like the idea of subclassing this. Just because
some people do not follow standards in no reason to not try to
support in the best possible manner.
I agree with prefixing them with x- into attribute types. Servers
which support extendedAttributeInfo probably do not use x- in
attribute types anyway. However I have attached an alternate patch I
would like you to try.
Graham.
Index: lib/Net/LDAP/Schema.pm
===================================================================
--- lib/Net/LDAP/Schema.pm (revision 519)
+++ lib/Net/LDAP/Schema.pm (working copy)
@@ -248,6 +248,8 @@
auxiliary
);
+my %xat_flags = map { ($_,1) } qw(indexed system-only);
+
#
# These items can have lists arguments
# (name can too, but we treat it special)
@@ -259,6 +261,7 @@
#
my %type2attr = qw(
at attributetypes
+ xat extendedAttributeInfo
oc objectclasses
syn ldapsyntaxes
mr matchingrules
@@ -323,10 +326,11 @@
# The first token is the OID
my $oid = $schema_entry{oid} = shift @tokens;
+ my $flags = ($type eq 'xat') ? \%xat_flags : \%flags;
while(@tokens) {
my $tag = lc shift @tokens;
- if (exists $flags{$tag}) {
+ if (exists $flags->{$tag}) {
$schema_entry{$tag} = 1;
}
elsif (@tokens) {
@@ -376,7 +380,7 @@
#
# Store the elements by OID
#
- $schema->{oid}->{$oid} = \%schema_entry;
+ $schema->{oid}->{$oid} = \%schema_entry unless $type eq 'xat';
#
# We also index elements by name within each type
@@ -388,6 +392,16 @@
}
}
+ # place extendedAttributeInfo into attribute types
+ if (my $xat = $schema->{xat}) {
+ foreach my $xat_ref (values %$xat) {
+ my $oid = $schema->{oid}{$xat_ref->{oid}} ||= {};
+ while (my($k,$v) = each %$xat_ref) {
+ $oid->{"x-$k"} = $v unless $k =~ /^(oid|type|name|aliases)$/;
+ }
+ }
+ }
+
$schema->{entry} = $entry;
return $schema;
}