# Table Maybe???


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers # Table Maybe???
# 1  
Old 11-15-2010
Question # Table Maybe???

hey guys I am creating Users in LDAP.
Problem is when I create a User they need to have a uidNumber and a gidNumber and they need to be unique.

the command i issue is:
ldapsearch -x -b 'dc=beasty,dc=netlab,dc=albury,dc=tafe' '(objectclass=posixAccount)' uidnumber|grep uidNumber

which prints out:

uidNumber: 1001
uidNumber: 1064
uidNumber: 1004
uidNumber: 1073
uidNumber: 1002
uidNumber: 1005

Is there a way/script that will automaticaly add in the users uidNumber and not use the same one that had already been created.
so then is will add it to my ldif file
uidNumber:

gidNumber:


Last edited by jmorey; 11-17-2010 at 07:41 PM..
# 2  
Old 11-16-2010
You can try this:
Code:
newuidnr=$( ldapcommand bla bla ... uidnumber | awk '/uidNumber/&&$2>t{t=$2}END{print t+1}')

Which will add 1 to the highest uid so far (uidnumber is LDAP speak Smilie )
# 3  
Old 11-17-2010
hey Scrutinizer thanks for all your help but i am still a bit confused...
this is what i got
#Edit UDI
print
"Hit enter to display a list of users and what UDI/GID have been used.\n";

my
$Enter2= <STDIN>;

my
$UIDNumber= (

"ldapsearch -x -b 'dc=beasty,dc=netlab,dc=albury,dc=tafe' '(objectclass=posixAccount)' uidnumber|grep uidNumber"
);
system
"$UIDNumber";

print
"Enter Users UDI/GID Number other than specified above (eg.1001).\n";

my
$UDI= <STDIN>;

chomp $UDI;

which then falls into

my
$stuff= <<LDIF;
dn: uid=$UserName,ou=$OU,ou=$OU2,$DC3
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: posixAccount
objectClass: shadowAccount
uid: $UserName
cn: $LastName $FirstName
givenName: $GivenName
mail: $UserName\@$Email
sn: $FirstName
uidNumber: $UDI
gidNumber: $UDI
homeDirectory: /home/$UserName
loginShell: /bin/tcsh
userPassword: $b

dn: cn=$UserName,ou=$OU3,ou=$OU2,$DC3
objectClass: posixGroup
cn: $UserName
gidNumber: $UDI
description: Private group for the \"$UserName\" user"
LDIF
open
MYLDIF, ">", "init.ldif";

print
MYLDIF $stuff;

close MYLDIF;


how do i use the command above is it something like
"newuidnr=$(
ldapsearch -x -b 'dc=beasty,dc=netlab,dc=albury,dc=tafe' '(objectclass=posixAccount)' uidnumber|grep uidNumber
| awk '/uidNumber/&&$2>t{t=$2}END{print t+1}')"

# 4  
Old 11-18-2010
Hi, like this, I'd say:
Code:
newuidnr=$( ldapsearch -x -b 'dc=beasty,dc=netlab,dc=albury,dc=tafe' '(objectclass=posixAccount)' uidnumber | awk '/uidNumber/&&$2>t{t=$2}END{print t+1}')

you can leave out the grep and you should not use the double quotes at the beginning and end.
This User Gave Thanks to Scrutinizer For This Post:
# 5  
Old 11-18-2010
ok i got one more question lol.
i want to create a directory for a user but make it work for whoever logs on so this is what i issue

my
$whoamI= ("whoami");
chomp


$whoamI;
my


$Add_User= ("mkdir /home/$whoamI/users");
my


$Add_ldif= ("mkdir /home/$whoamI/users/init.ldif");
chomp $whoamI;
and is seems to not work

but when i want to use it for adding my Ldif file like this:

#Load file into the LDAP server
my


$LoadFile= ("ldapadd -U $whoamI -w password -f init.ldif");
system $LoadFile;
it does work but comes up with the "$whoamI"



Last edited by jmorey; 11-18-2010 at 07:31 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Web Development

Getting Rid of Annoying Bootstrap Table Borders and Wayward Table Lines

Bootstrap is great; but we have had some issues with Bootstrapped <tables> (and legacy <fieldset> elements) showing annoying, wayward lines. I solved that problem today with this simple jQuery in the footer: <script> $(function(){ $('tr, td, fieldset,... (0 Replies)
Discussion started by: Neo
0 Replies

2. Shell Programming and Scripting

awk to convert table-by-row to matrix table

Hello, I need some help to reformat this table-by-row to matrix? infile: site1 A:o,p,q,r,s,t site1 C:y,u site1 T:v,w site1 -:x,z site2 A:p,r,t,v,w,z site2 C:u,y site2 G:q,s site2 -:o,x site3 A:o,q,s,t,u,z site3 C:y site3 T:v,w,x site3 -:p,routfile: SITE o p q r s t v u w x y... (7 Replies)
Discussion started by: yifangt
7 Replies

3. UNIX and Linux Applications

Help in copying table structure to another table with constraints in Oracle

hi, i need to copy one table with data into another table, right now am using create table table1 as select * from table2 i want the constraints of table1 to be copied to table2 also , can anyone give me some solution to copy the constraints also, now am using oracle 10.2.0.3.0... (1 Reply)
Discussion started by: senkerth
1 Replies

4. UNIX and Linux Applications

Single table or split the table

I have an application that collect data from 10 server every minutes and stored to mysql db,. there are about 10K record from each server on every minutes. that data will need to stored in 1 month. Which ones is better, create single table for all servers and put field to identified data... (3 Replies)
Discussion started by: before4
3 Replies

5. Shell Programming and Scripting

Build a table from a list by comparing existing table entries

I am new to this shell scripting.... I have a file which contains list of users. This files get updated when new user comes into the system. I want to create script which will give a table containing unique list of users. When I say unique, it means script should match table while parsing... (3 Replies)
Discussion started by: dchavan1901
3 Replies

6. UNIX for Dummies Questions & Answers

Creating a condensed table from a pre-existing table in putty

Hello, I'm working with putty on Windows 7 professional and I'd like to know if there's a way to gather specific lines from a pre-existing table and make a new table with that information. More specifically, I'd like the program to look at a specific column, say column N, and see if any of the... (5 Replies)
Discussion started by: Deedee393
5 Replies

7. UNIX and Linux Applications

create table via stored procedure (passing the table name to it)

hi there, I am trying to create a stored procedure that i can pass the table name to and it will create a table with that name. but for some reason it creates with what i have defined as the variable name . In the case of the example below it creates a table called 'tname' for example ... (6 Replies)
Discussion started by: rethink
6 Replies

8. Shell Programming and Scripting

select values from db1 table and insert into table of DB2

Hi I am having three oracle databases running in three different machine. their ip address is different. from one of the DB am able to access both the databases.(means am able to select values and insert values in to tables individually.) I need to fetch some data from DB1 table(say DB1 ip is... (2 Replies)
Discussion started by: aemunathan
2 Replies

9. Shell Programming and Scripting

Check the record count in table (table in oracle)

I have requirement: 1) Check the record count in table (table in oracle) 2) If records exists generate the file for existing records and wait for some time then Go to sleep mode and Again check the record count after 10 min.......... (Loop this process if record count >0). 3) Generate touch... (1 Reply)
Discussion started by: kamineni
1 Replies

10. Shell Programming and Scripting

Check the record count in table (table in oracle)

I have requirement: 1) Check the record count in table (table in oracle) 2) If records exists generate the file for existing records and wait for some time (Go to sleep mode) and Again check the record count after 10 min.......... (Loop this process if record count >0). 3) Generate touch... (1 Reply)
Discussion started by: kamineni
1 Replies
Login or Register to Ask a Question