#!/usr/bin/perl
$|++;
use strict;
use warnings;
use Net::LDAP;
require "cliebow.pm";
use vars qw($sid $rootpw $rootdn $ip $ldapserver $dn $attr @allusers @newstudents %mysmb $lastuid $ldap $gecos $username $mesg $year $uid $firstname $lastname $pw $user $groupsid);
#parse smb.conf and make a hash of it
	%mysmb=&read_conf();
	$dn=$mysmb{"ldap suffix"};
	$rootdn="cn=root,$dn";#dc=ehs.dc=ellsworthschools.dc=org";
	$ip="localhost";
	$ldapserver="localhost";
	$attr="cn";
#get the pw from ldap.secret
	&getldap_pw;

#get the sid
	&getsid;
#get next usable uid number
	&lastuid;
#reads newusers from a file into @newstudents
	&readfile("/var/www/admin/students");
#Lets split on commas
	foreach my $yoyo (@newstudents){
		my @users=split(",","$yoyo");
	 $firstname=$users[0];
	 $lastname=$users[1];
	 $gecos=join(" ",$firstname,$lastname);
	$year=$users[2];
	$pw=$users[3];
	$username=$users[4];	
print "$gecos\n"
}
 $groupsid=join("-",$sid,$lastuid);
chomp $groupsid;	
	print "$groupsid\n";
	print "$username\n";
	print "$dn\n";
	print "$year\n";
	print "$rootdn\n";
	print "$rootpw\n";
	print "$pw\n";
	print "$lastuid\n";
	$user="cn=$username,ou=$year,ou=Students,ou=People,$dn";
	print "user-->$user\n";
#Wait here before going on#####################################
	my $waitasec=readline(*STDIN);
&addrecord;

#increment uid
&updatelastuid;	
##reset uid in sambaDomainNames
#&mkhomedir;


