0

I'm trying to create a web server which needs for some user authentication within the server itself. I need to do it with Perl so I decided to try to use an LDAP server in localhost.

I've been trying to use the script below. Everything is configured correctly (as i tried to search for entries aready configured), but, when I try to run the script, it tells me "Index generation failed"

my $ldap = Net::LDAP->new( '127.0.0.1' ) or die "$@";

my $mesg = $ldap->bind ('cn=admin, dc=ramal, dc=com',
                        password=>'<admin_password>'
                     );

#$mesg->code or die $mesg->error;

my $result = $ldap->add('uid=pruebaPerl, ou=User, dc=ramal, dc=com',
                        attrs=> [
                                'uid' => 'pruebaPerl',
                                'cn' => 'Usuario de prueba de Perl',
                                'objectclass' => ['account', 'posixAccount', 'shadowAccount'],
                                'userPassword' => '<hashed password>',
                                'loginShell' => '/bin/bash',
                                'uidNumber' => 2001,
                                'gidNumber' => 2001,
                                'homeDirectory' => '/home/pruebaPerl'
                        ]
                );

$result->code and warn "Failed to add entry: ", $result->error;

$mesg = $ldap->unbind

So, I think something's wrong in the arguments for add but I don't know what. Any help is welcomed.

2
  • Is the password hash real? Commented May 22, 2019 at 15:51
  • @choroba yes, sorry, the passwords were all real, already edited them out. Commented May 22, 2019 at 18:07

1 Answer 1

1

Definitely an issue on the slapd side. Not a perl issue.

This old thread https://www.openldap.org/lists/openldap-software/200407/msg00007.html suggests that maybe your test ldap structure got created wrong using slapadd instead of using ldapadd. Or you have a permission issue.

Have you tried strace 'ing the slapd process ?

Also try to remove the spaces in 'uid=pruebaPerl, ou=User, dc=ramal, dc=com' and 'cn=admin, dc=ramal, dc=com'

Sign up to request clarification or add additional context in comments.

2 Comments

I've tried running the program with root priviledges and also removing the spaces, but none of the solutions worked. How can I enable the strace'ing of the slapd process?
After doing some research it seems you were right and the ldap structure got corrupted somewhere with slapadd and, after restoring, it works so thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.