#!/usr/bin/perl ########################################################################################### # PERL SCRIPT FOR UP POLICY CREATION # Author: Ritu Sati # eMail : sritu@novell.com # Version : 1.0 ############################################################################################## if ($#ARGV != 3) { print " Usage: Perl up.pl adminconetxt password serverip port "; print "\n Example: perl up.pl cn=admin,o=test test 101.101.101.101 389"; print "\n"; exit; } $admincontext=$ARGV[0]; $passwd=$ARGV[1]; $serverip=$ARGV[2]; $port=$ARGV[3]; chomp ($admincontext); chomp ($passwd); ################################################################################################## my $invalid_choice = 1; while ($invalid_choice) { print(" \n 1. To create up policy and assign it to a user or container"); print(" \n 2. To asign existing UP policy to a user or container "); print("\n 3. To Exit"); print("\n Enter your choice: "); my $choice = ; if ( $choice == 1 ) { print "Please enter the up policy dn eg: cn=up,o=novell "; $upcontext=; chomp ($upcontext); print "\n Please enter the user or conatiner context eg: ou=test,o=novell "; $container=; chomp ($container); &up_create; &up_assign; print("\n"); } elsif ( $choice == 2 ) { print "Please enter the existing up policy dn eg: cn=up,o=novell "; $upcontext=; chomp ($upcontext); print "\n Please enter the user or conatiner context eg: ou=test,o=novell "; $container=; chomp ($container); &up_assign; print("\n"); } elsif ( $choice == 3 ) { exit; } else { print("\n Invalid choice entered\n\n"); redo; } $invalid_choice = 0; } ###################################################################################################### sub up_create { $op = open (S, ">up-add.ldif"); print S "dn: $upcontext"; print S "\nnspmExtendedCharactersAllowed: TRUE"; print S "\nnspmCaseSensitive: TRUE"; print S "\nnspmSpecialAsLastCharacter: TRUE"; print S "\nnspmSpecialAsFirstCharacter: TRUE"; print S "\nnspmSpecialCharactersAllowed: TRUE"; print S "\nnspmNumericAsLastCharacter: TRUE"; print S "\nnspmNumericAsFirstCharacter: TRUE"; print S "\nnspmNumericCharactersAllowed: TRUE"; print S "\nnspmMaximumLength: 12"; print S "\nnspmAdminsDoNotExpirePassword: FALSE"; print S "\nnspmConfigurationOptions: 852"; print S "\npasswordUniqueRequired: FALSE"; print S "\npasswordMinimumLength: 4"; print S "\npasswordAllowChange: TRUE"; print S "\nobjectClass: nspmPasswordPolicy"; print S "\nobjectClass: Top\n"; print S "\n"; close (S); system ("ice -S ldif -f up-add.ldif -a -c -D ldap -s $serverip -p $port -d $admincontext -w $passwd "); } ############################################################################################################# sub up_assign { $op = open (R, ">up-modify.ldif"); print R "dn: $container"; print R "\nchangetype: modify"; print R "\nadd: nspmPasswordPolicyDN"; print R "\nnspmPasswordPolicyDN: $upcontext"; print R "\n"; close (R); system ("ice -S ldif -f up-modify.ldif -m -c -D ldap -s $serverip -p $port -d $admincontext -w $passwd "); } #########################################################################################################