Add user to Remote Desktop Users (Perl)

This code can be found in Chapter 17 of Windows Server 2003 Security Cookbook

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.

# This code adds a user to the the Remote Desktop Users group/
# ------ SCRIPT CONFIGURATION ------

use Win32::OLE;

$strGroupDN = '<GroupDN>';
# e.g. cn=Remote Desktop Users,cn-builtin,dc=rallencorp,dc=com

$strMemberDN = '<MemberDN>';
# e.g. cn=jsmith,cn=users,dc=rallencorp,dc=com
# ------ END CONFIGURATION ---------
$objGroup = Win32::OLE->GetObject('LDAP://' . $strGroupDN);
# Add a member
$objGroup->Add('LDAP://' . $strMemberDN);
print "$strMemberDN added to group $strGroupDN\n";

This code has been viewed 2002 times.

New from the creators of TechTasks.com: StatSheet.com