How to read a user's OCS Meeting Policies using Perl - The user's msRTCSIP-UserPolicy attribute contains a DNwithBinary object (or an array of them). The DN's, once retrieved, point to OCS meeting policy objects, that contain policy settings stored in XML format.
Here's a Perl script that will find a user, read the policies applied to the user, and print out the settings in those policies.
use Win32::OLE; use XML::Simple;
$user="myUser";
# search for the user to find the distinguishedName
$dse=Win32::OLE->GetObject("LDAP://RootDSE");
$root=$dse->Get("RootDomainNamingContext");
$adpath="GC://$root";
$base="<".$adpath.">";
$connection = Win32::OLE->new("ADODB.Connection");
$connection->{Provider} = "ADsDSOObject";
$connection->Open("ADSI Provider");
$command=Win32::OLE->new("ADODB.Command");
$command->{ActiveConnection}=$connection;
$command->{Properties}->{'Page Size'}=1000;
$rs = Win32::OLE->new("ADODB.RecordSet");$command->{CommandText}="$base;(&(objectCategory=User)((cn=$user)(samaccountname=$user)));distinguishedName;subtree";
$rs=$command->Execute;until ($rs->EOF){
$dn=$rs->Fields(0)->{Value};
$rs->MoveNext;
}
#retrieve the user's meeting policies
$userObj=Win32::OLE->GetObject("LDAP://$dn");
$pol=$userObj->Get("msRTCSIP-UserPolicy");
if(ref($pol) eq "ARRAY"){
foreach $p (@{$pol}){
&readPolicy($p);
}
}else{
&readPolicy($pol);
}
sub readPolicy{
$pol=shift;
if(!$pol){ print "no policy set\n"; exit;}
print "$pol->{DNString}\n";
$polObj=Win32::OLE->GetObject("LDAP://$pol->{DNString}");
$policyContent=$polObj->Get("msRTCSIP-PolicyContent");
$hashref=XMLin($policyContent);
foreach $k (sort keys %{$hashref->{property}}){
print "$k:\t$hashref->{property}->{$k}->{content}\n";
}
print "\n";
}



8:47 AM
Brian Seltzer

Image icons used on this site are courtesy of Oxygen-icons.org
0 comments:
Post a Comment