Use the blue Nav bar above to access the main index pages!

List Linux Users in Your Active Directory using Perl

A Script to List Linux Users in Active Directory:  Here's a Perl script that will search for users in your Active Directory that have the unix attributes set. The unix attributes that are most often used are uidNumber, gidNumber, unixHomeDirectory, and loginShell. The script does an ADODB search for users whose uidNumber = * meaning that it is set to something other than blank, returns the results, and displays the attributes. This is very handy since Microsoft does not display these attributes in the GUI. To learn how to allow linux users to logon using their Active Directory account, see my post about Active Directory Authentication for Linux

use Win32::OLE;
$connection = Win32::OLE->new("ADODB.Connection");
$connection->{Provider} = "ADsDSOObject";
$connection->Open("ADSI Provider");
$command->{Properties}->{'Page Size'}=1000;
$rs = Win32::OLE->new("ADODB.RecordSet");
print "\n===================\t\t===  ===  =======\t=====\n";
print "PRID (Display Name)\t\tUID  GID  HomeDir\tShell\n";
print "===================\t\t===  ===  =======\t=====\n\n";
until ($rs->EOF){
 $users{$uidNumber}="$sam ($disp)\t$uidNumber  $gidNumber  $unixHomeDirectory\t$loginShell\t$dn";
foreach $user (sort keys %users){
 print "$users{$user}\n";


Post a Comment

Related Posts Plugin for WordPress, Blogger...