/[A3C]/bin/ldap2model.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /bin/ldap2model.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 98 - (hide annotations)
Wed Apr 30 21:27:54 2008 UTC (15 years, 11 months ago) by dpavlin
File MIME type: text/plain
File size: 1161 byte(s)
minimal LDAP schema to Jifty model generator

We are not using dynamic class generation (a.k.a. Jifty magic)
here because models generated this way will probably have to be
manually edited anyway.
1 dpavlin 98 #!/usr/bin/perl
2     use warnings;
3     use strict;
4    
5     # schema2model.pl - convert LDAP schema file into jifty model
6     #
7     # 04/30/08 20:55:21 CEST Dobrica Pavlinusic <dpavlin@rot13.org>
8    
9     use Net::LDAP::Schema;
10     use Data::Dump qw/dump/;
11    
12     my ( $path, $objectClass ) = @ARGV;
13    
14     die "usage: $0 path/to/schema.ldif inetOrgPerson\n" unless $path && $objectClass;
15    
16     my $schema = Net::LDAP::Schema->new;
17     $schema->parse ( $path ) or die $schema->error;
18    
19     sub entry {
20     my ( $e, $add ) = @_;
21     my $out = qq/\tcolumn $_->{name} =>\n\t\tlabel is _('$_->{desc}')/;
22     $out .= qq/,\n\t\t# single-value/ if $_->{'single-value'};
23     $out .= qq/,\n\t\tmax_length is $_->{max_length}/ if $_->{'max_length'};
24     $out .= qq/,\n\t\t$add/ if $add;
25     $out .= qq/;\n\n/;
26     return $out;
27     }
28    
29     my $model = qq/\t# $objectClass super: / . join(' ', $schema->superclass($objectClass)). qq/\n\n/;
30    
31     $model .= qq/\t# $objectClass must:\n\n/;
32    
33     map {
34     warn "# $objectClass must: ",dump( $_ );
35     $model .= entry( $_, 'is mandatory' );
36     } $schema->must( $objectClass );
37    
38     $model .= qq/\t# $objectClass may:\n\n/;
39    
40     map {
41     warn "# $objectClass may: ",dump( $_ );
42     $model .= entry( $_ );
43     } $schema->may( $objectClass );
44    
45     print $model;

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26