+ my %ad_args;
+ if ($config->{verify}) {
+ $ad_args{verify} = 'require';
+ if (defined(my $cert = $config->{cert})) {
+ $ad_args{clientcert} = $cert;
+ }
+ if (defined(my $key = $config->{certkey})) {
+ $ad_args{clientkey} = $key;
+ }
+ if (defined(my $capath = $config->{capath})) {
+ if (-d $capath) {
+ $ad_args{capath} = $capath;
+ } else {
+ $ad_args{cafile} = $capath;
+ }
+ }
+ } elsif (defined($config->{verify})) {
+ $ad_args{verify} = 'none';
+ }
+
+ my $ldap = Net::LDAP->new($conn_string, %ad_args) || die "$@\n";
+
+ $username = "$username\@$config->{domain}"