Thursday, February 8, 2024

[SOLVED] first login to enter website with username and passwort

Issue

I have to trying always for Perl, .htaccess and httppd.conf with different Username and Password from LDAP Search. But it it out of all recognition for username and password. Maybe I am wrong for programmer or what?

Perl:

Package:

use Net::LDAP;
use Net::LDAP::Extension::SetPassword;

Function:

my $ldapserver="ldap.server.com";
my $dn="CN=Company IT,OU=Standard Users,OU=Users,OU=Company IT AG,OU=Prod,DC=server,DC=server,DC=com";


my $ldap = Net::LDAP->new( $ldapserver, debug =>0 ) or die $@;
my $result = $ldap->bind( $dn, password => password );

#$result->SetPassword('user');

$result = $ldap->search(
base => "OU=Standard Users,OU=Users,OU=Company IT AG,OU=Prod,DC=server,DC=server,DC=com",
filter => "(mailNickname="*")"

httpd:

<Directory "/opt/csw/apache2/share/cgi-bin">
    SetEnv LD_LIBRARY_PATH "/opt/csw/apache2/lib:/opt/oracle/product/11.2.0.4/instantclient_11g"
    AddHandler cgi-script .cgi .pl .py
    AllowOverride Options
    Options +ExecCGI
    Order allow,deny
    Allow from all

    AuthName "Enter Your Network Username/Password"
    AuthType Basic
    AuthBasicProvider ldap
    AuthBasicAuthoritative off
    AuthLDAPURL ldap://ldap.server.com
    AuthLDAPBindDN "CN=Company IT,OU=Standard Users,OU=Users,OU=Company IT AG,OU=Prod,DC=server,DC=server,DC=com"
    AuthLDAPBindPassword password
    AuthLDAPRemoteUserAttribute mailNickname
    require valid-user
</Directory>

htaccess:

AuthName "Enter Your Network Username/Password"
AuthType Basic
Options +ExecCGI
AuthBasicProvider ldap
AuthBasicAuthoritative off
AuthLDAPURL ldap://ldap.server.com
AuthLDAPBindDN "CN=Company IT,OU=Standard Users,OU=Users,OU=compant IT AG,OU=Prod,DC=server,DC=server,DC=com"
AuthLDAPBindPassword password
AuthLDAPRemoteUserAttribute mailNickname
require valid-user

Solution

AuthLDAPBindDN must be the user to consult the ldap, AuthLDAPURL must be not only the ldap server but the entire LDAP patch Active Directory. Like

AuthLDAPBindDN "userldap@domain"
AuthLDAPURL "ldap://ldap.server.com/OU=Standard Users,OU=Users,OU=compant IT AG,OU=Prod,DC=server,DC=server,DC=com?sAMAccountName?sub?(objectClass=*)"


Answered By - Joao Vitorino
Answer Checked By - Robin (WPSolving Admin)