I want to bind a LDAP connection without giving the script a username and the password. At the moment I am asking the user for his password like this and bind the connection:
chomp($password = <STDIN>);
$server = "NAME_OF_MY_DC_SERVER";
$ldap = Net::LDAP->new($server);
$ldap or die "$@\n";
$ldap->bind('USERNAME', password => $password);
But this is not what I want. I want the script to bind the LDAP connection automatically with the credentials of the user running the script. Is there an opportunity to get the login information of the current user to pipe it to the binding operator?
I am working in a Windows-Environment with an ActiveDirectory.
No, unfortunately not.
On windows, the current login can't be extracted for security reasons. Your best bet would be to use the .NET framework with C# and connect directly via the AD API. Windows should handle the authentication automatically for you then. You won't be using Perl for that though.