The script uses an ADO query, that searches for users with OCS enabled (msRTCSIP-UserEnabled=True). The output file is a tab-delimited text file that can be opened in Excel.
use Win32::OLE;
open OUT,">OCSUserList.txt";
$dse=Win32::OLE->GetObject("LDAP://RootDSE");
$root=$dse->Get("RootDomainNamingContext");
$adpath="GC://$root";
$base="<".$adpath.">";
$c = Win32::OLE->new("ADODB.Connection");
$c->{Provider} = "ADsDSOObject";
$c->Open("ADSI Provider");
$comm=Win32::OLE->new("ADODB.Command");
$comm->{ActiveConnection}=$c;
$comm->{Properties}->{'Page Size'}=1000;
$rs = Win32::OLE->new("ADODB.RecordSet");
$comm->{CommandText}="$base;(msRTCSIP-UserEnabled=TRUE);displayName,msRTCSIP-PrimaryUserAddress,msRTCSIP-PrimaryHomeServer,msRTCSIP-OptionFlags;subtree";
$rs=$comm->Execute;
until ($rs->EOF){
$displayName=$rs->Fields(0)->{Value};
$sip=$rs->Fields(1)->{Value};
$pool=$rs->Fields(2)->{Value};
$flags=$rs->Fields(3)->{Value};
print "$sip\n";
print OUT "$displayName\t$sip\t$pool\t$flags\n";
$rs->MoveNext;
}
close OUT;

No comments:
Post a Comment