On Fri, Dec 5, 2014 at 5:35 AM, Jitendra Barik <jbarik...@gmail.com> wrote:

> Hi All,
>
> Could you please let me know please, why this code is not working as I am
> trying to validate my email id to my mail server?
>
>
> my $ldap_server = "google.com"; # or some local mail server
> my $ldap = Net::LDAP -> new($ldap_server) or die "This is Error: $@";
> my $username = "username"; #ldap user name
> my $password = "password"; #ldap passsword
>  my $mesg = $ldap->bind($username, password => $password);
>  $results=sprintf("%s",$mesg->error);
>  if ($results=~/Success/)
> {
>    print "Thank you. You have successfully authenticated";
> }
> else
> {
>    print "You are a horrible, Try again.";
>
> }
> $mesg->code && die $mesg->error;
>
> print "Bye\n";
>
> $mesg = $ldap->unbind;   # take down session
>


well, you are making some assumptions in there.

The first one is that you e-mail provider uses ldap to save your e-mail
address? Are you sure of that?

The second one is: are you sure that you can talk ldap to the host you save
in $ldap_server? If you can't, it won't work.

You should see that, by the way, in the $@ error (your 2nd line). So it
would be interesting to know what you get there, because that is the main
troubleshooting info you will need.

The info on $mesg-error is also important, you get ldap errors, and you can
easily find what they mean using a search engine.

Having said that, most times even if the user accounts are stored in ldap,
you will not be able to query an ldap server to bind using ldap when using
internet providers (if you are trying to query a university ldap server you
might get lucky, using Active Directory inside the firewall too). I am
pretty sure google.com will not let you ;-) (I just tried) and certainly
not unless you are using TLS because that would mean you are sending your
name/password unencrypted over the wire.

--
Groeten,
natxo

Reply via email to