Hello,
I am trying to retrieve the accountexpirationdate field for a user account
using Win32::OLE and ldap using the following code :-
use Win32::OLE;
use strict;
my($user)="cn=username"; # fill in as appropriate
my($container)="ou=users container";
my($domain)="dc=my,dc=domain";
my($aduser)=Win32::OLE->GetObject("LDAP://$user,$container,$domain");
die "Can't connect to ad for $user, ", Win32::OLE->LastError, "\n" if
(Win32::OLE->LastError() != 0);
print "accountexpires = ", $aduser->Get("accountExpires"), "\n";
This returns
accountexpires = Win32::OLE=HASH(0x1a752a8)
There are no keys in the Win32::OLE Hash and therefore no data that I can
read. To make matters worse, querying the property 'accountExpirationDate'
returns nothing. What I have been able to make work is the following VB code
:-
user="cn=username"
container="ou=users container"
domain="dc=my,dc=domain"
set aduser=GetObject("LDAP://" + user + "," + container + "," + domain)
dtmAccountExpiration = aduser.AccountExpirationDate
If err.number = -2147467259 Or _
dtmAccountExpiration = "1/1/1970" Then
WScript.echo "No account expiration specified"
Else
WScript.echo "Account expiration: " & aduser.AccountExpirationDate
End If
Has anyone managed to actually read this property out and therefore usable
in a perl script? If so, can they provide an example?
Bret
--
Bret Giddings, Systems Manager, Computing Service, University of Essex
Tel: (01206) 872577 Email: [EMAIL PROTECTED] Fax: (01206) 860585
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs