Created
July 14, 2012 15:28
-
-
Save shelling/3111831 to your computer and use it in GitHub Desktop.
import schema ldif with Net::LDAPI and Authen::SASL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| # USAGE: | |
| # perl ldapi.pl schema.ldif | |
| # will have the same result as running | |
| # ldapadd -Y EXTERNAL -H ldapi:/// -f schema.ldif | |
| use Modern::Perl; | |
| use Net::LDAP; | |
| use Authen::SASL; | |
| use Net::LDAP::LDIF; | |
| my $ldapi = Net::LDAP->new("ldapi://"); | |
| $ldapi->bind( | |
| undef, | |
| sasl => Authen::SASL->new(mechanism => 'EXTERNAL') | |
| ->client_new("ldap", "localhost"), | |
| ); | |
| my $ldif = Net::LDAP::LDIF->new($ARGV[0], "r", onerror => "die"); | |
| my $entry = $ldif->read_entry; | |
| say $entry->ldif; | |
| my $msg = $ldapi->add($entry); | |
| warn $msg->error if $msg->code; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment