use Win32::OLE; use Win32::OLE::Const ('Active DS'); my $user = Win32::OLE->GetObject("LDAP://$distinguishedName"); my $SID = $user->{objectSID};