Listing15_Transfer_PDC (Perl)
This code can be found in
Chapter 7 of Managing Enterprise Active Directory Services
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the Perl code from this site.
# From the book "Managing Enterprise Active Directory Services"
# ISBN: 0-672-32125-4
use strict;
use Net::LDAP;
my $server = 'dc1';
my $user = 'administrator@xyz.com';
my $passwd = 'password';
my $ldap = Net::LDAP->new($server)
or die "Could not connect to $server";
my $bind = $ldap->bind($user, password => $passwd);
die "Could not bind to $server" if $bind->code;
# Connect to RootDSE
my $rootdse = $ldap->search(base => '',
filter => '(objectclass=*)',
scope => 'base');
# Transfer the PDC role
my $res = $rootdse->entry(0)->add( becomePDC => 1);
$res = $rootdse->entry(0)->update( $ldap );
if ($res->code) {
print "Could not transfer FSMO: ",$res->error,"\n";
}
else {
print "Successfully initiated FSMO transfer to $server\n";
}
$ldap->unbind;
|
This code has been viewed 623 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|