Matchete
Matchete

Reputation: 1

Perl - Win32::AD::User - can't seem to figure out how to retrieve a DN

I'm trying to get the DN for a given username in a csv file using the Win32::ad::user module in Perl, but I can't seem to get the syntax right. Here's my code... (domain name has been replaced)

#!/usr/bin/perl
#use strict;
use warnings;
use Win32::AD::User;
use Text::CSV;
use Net::LDAP;

my $file = "Users.csv";
my $csv = Text::CSV->new();

open (CSV, "<", $file) or die $!;

while (<CSV>) {
if ($csv->parse($_)) {
    my @username = $csv->fields();
    my $user = $username[0];
    my $adstring = join('', $user, ',user",',$user, '"');
    my $acdiruser=Win32::AD::User->new('WinNT://my.domain.EDU/ ',$user);
    $acdiruser->get_info();
    print join ("\n", $acdiruser->get_property( dn ));

}
}
close CSV;

Any ideas?

Thanks!!!

EDIT: The error was Bareword "dn" not allowed while "strict subs" in use at T:\Thunderbird Conversion\GetOU.pl line 22, line 558. Execution of T:\Thunderbird Conversion\GetOU.pl aborted due to compilation errors.

Upvotes: 0

Views: 479

Answers (2)

Matchete
Matchete

Reputation: 1

So, this was an issue with the Win32::AD::User module- When I was using Quotes, I was failing because I was trying to apply LDAP properties to a function that only accepts WinNT properties. I'll be using Net::Ldap instead.

Upvotes: 0

user1126070
user1126070

Reputation: 5069

I think it maybe a typo.

$acdiruser->get_property( 'dn' );

regards,

Upvotes: 1

Related Questions