Tuesday, July 24, 2007

Find and Remove files recusively Linux

find ./ -name subsub* -ok rm -r {} \;

find ./ -name *.class -ok rm -r {} \;

Will search for any file or (sub)dir and delete it after asking politly…

find ./ -name sub* -exec rm -rf {} \;

Will search for any file or (sub)dir, delete it and won’t tell anyone at all…

The trick is, the {} in the rm command, will be repaced by what ever the find commands finds… (obviously, you dont have to delete..

LDAP SCHEMA DESIGN

COLLEGE LDAP Schema - CASE STUDY

Description

This document describes about design of ldap schema for a college administration department. College will have various departments like mechanical, chemical, Electronics, civil etc.. Each department will of various branches. For example electronics department can have Electronics & Communication Engineering, Electronics & Electrical Engineering, Electronics & Instrumentation Engineering, Computer Science Engineering, Computer Science & Information Technology, Electronics & Computer Science etc.. Each branch will have in charge, number of students, teaching and non teaching staff. Each student will be attending set of subjects for an academic year. Each teaching staff & non teaching staff will have salary details. Framing the requirements into hierarchical structure, following LDAP tree depicts the tree structure.

Note: the oids used in this article are selected randomly and they are for temporary use and please don't use oid's mentioned in this article. Use your own oids. The oids in this article will be changed in the next release

Schema design

From the above description, the objectclasses identified are COLLEGE, DEPARTMENT, BRANCH, ACADEMIC, STUDENT, SUBJECTS, STAFF and SALARY and each object class consists of following attributes.

COLLEGE DEPARTMENT BRANCH ACADEMIC STUDENT
collegeName deptName branchName academicYear studentName
collegePrincipal deptHead BranchHead studentNumber
collegePresident branchNumberOfStudents studentAddress
collegeSecretary studentAcademicYear
collegeBoardMember studemtCourse
studentStatus
studentYear

SUBJECTS STAFF SALARY
subjectName staffName salaryBASIC
subjectMarks staffID salaryDA
subjectCode staffAddress salaryHRA
staffQualification salaryAllowance
staffDesignation salaryTotal
staffBranch
staffType

The top node is college with unique DN as o=college. College will have different departments like Civil, Electronics, Mechanical etc.. The number of child nodes depends on the number of departments in the college. Let us take, college has two departments Civil and Electronics. Then the o=college parent node will have two child nodes deptName=Civil and deptName=Electronics. Each node can be identified as deptName=Civil,o=college and deptName=Electronics,o=college. If searched with DN deptName=Electronics,o=college, attributes at this entry will be retrieved. The subtree is

o=college | --------------------------------- | | deptName=Civil deptName=Electronics

Consider the department Electronics has three branches ECE, EEE & CSE. The DN for each branch will be branchName=ECE,deptName=Electronics,o=college, branchName=EEE,,deptName=Electronics,o=college and branchName=CSE,,deptName=Electronics,o=college.

Now take the branch ECE, each branch will have students and staff. Each student belongs to a particular year and each staff belongs to either teaching or non-teaching staff. So consider the sub tree under the dn branchName=ECE,deptName=Electronics,o=college is branchName=ECE | ----------------------------------------------------- | | ou=student ou=staff | | ------------------------------  p; --------------------------- | | | academicYear=1999-2000 academicaYear=2000-2001 ou=teaching ou=nonteaching

Each academicYear consists of students and each student will be studying the subjects, each staff will have salary details and subjects he/she is handling. The subtrees for academicYear, teaching and nonteaching are

ademicYear=1999-2000 ou=teaching ou=nonteaching | | | ---------------------------- & ----------------- ; ----------------- | | | | | | studentNumber=100 studentNumber=101 staffID=200 staffID201 staffID=300 staffID=301 | | | ---------------------- & ----------------- ou=Salary Details | | | | subjectCode=001 subjectCode=002 ou=Salary Details subjectCode=001

COLLEGE LDAP Tree

o=college | --------------------------------- | | deptName=Civil deptName=Electronics | ------------------------------------------ | | | branchName=EEE branchName=ECE branchName=CSE | ----------------------------------------------------- | | ou=student ou=staff | | ------------------------------  p; --------------------------- | | | academicYear=1999-2000 academicaYear=2000-2001 ou=teaching ou=nonteaching | | | ---------------------------- & ----------------- ; ----------------- | | | | | | studentNumber=100 studentNumber=101 staffID=200 staffID201 staffID=300 staffID=301 | | | ---------------------- & ----------------- ou=Salary Details | | | | subjectCode=001 subjectCode=002 ou=Salary Details subjectCode=001

Attributes

This section contains attribute file for College LDAP tree

attributetype ( 1.3.6.1.4.1.15490.1.1 NAME 'collegeName' DESC 'college name' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.2 NAME 'collegePrincipal' DESC 'college principal name' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.3 NAME 'collegePresident' DESC 'college president' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.4 NAME 'collegeSecretary' DESC 'college secretary name' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.5 NAME 'collegeBoardMember' DESC 'board member name' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) attributetype ( 1.3.6.1.4.1.15490.1.6 NAME 'deptName' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.7 NAME 'deptHead' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.8 NAME 'branchName' DESC 'board member name' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE) attributetype ( 1.3.6.1.4.1.15490.1.9 NAME 'branchHead' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.10 NAME 'branchNumberOfStudents' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.11 NAME 'studentName' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.12 NAME 'studentNumber' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15) attributetype ( 1.3.6.1.4.1.15490.1.13 NAME 'studentAddress' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.14 NAME 'studentAcademicYear' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.15 NAME 'studentCourse' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE) attributetype ( 1.3.6.1.4.1.15490.1.16 NAME 'studentStatus' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.17 NAME 'studentYear' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.18 NAME 'subjectName' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.19 NAME 'subjectMarks' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.20 NAME 'subjectCode' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.21 NAME 'staffName' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.22 NAME 'staffID' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.23 NAME 'staffAddress' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.24 NAME 'staffQualification' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.25 NAME 'staffDesignation' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.26 NAME 'staffDepartment' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.27 NAME 'staffBranch' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.28 NAME 'staffType' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.29 NAME 'salaryBasic' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.30 NAME 'salaryDA' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.31 NAME 'salaryHRA' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.32 NAME 'salaryAllowance' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.33 NAME 'salaryTotal' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.15490.1.34 NAME 'academicYear' DESC 'description' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )

Object class

This section gives objectclass details for College LDAP tree. objectclass ( 1.3.6.1.4.1.15490.2.1 NAME 'objCollege' SUP top STRUCTURAL DESC 'object class' MUST (collegeName $ collegePrincipal $ collegePresident $ collegeSecretary ) MAY (collegeBoardMember ) ) objectclass ( 1.3.6.1.4.1.15490.2.2 NAME 'objDepartment' SUP top STRUCTURAL DESC 'object class' MUST (deptName $ deptHead ) ) objectclass ( 1.3.6.1.4.1.15490.2.3 NAME 'objBranch' SUP top STRUCTURAL DESC 'object class' MUST (branchHead $ branchName $ branchNumberOfStudents ) ) objectclass ( 1.3.6.1.4.1.15490.2.4 NAME 'objStudent' DESC 'object class' SUP top STRUCTURAL MUST ( studentName $ studentNumber $ studentAddress $ studentAcademicYear $ studentCourse $ studentStatus $ studentYear ) ) objectclass ( 1.3.6.1.4.1.15490.2.5 NAME 'objSubject' DESC 'object class' SUP top STRUCTURAL MUST ( subjectCode $subjectName $ subjectMarks ) ) objectclass ( 1.3.6.1.4.1.15490.2.6 NAME 'objStaff' DESC 'object class' SUP top STRUCTURAL MUST ( staffName $ staffID $ staffAddress $ staffQualification $ staffDepartment $ staffBranch $ staffType) ) objectclass ( 1.3.6.1.4.1.15490.2.7 NAME 'objSalary' SUP top STRUCTURAL DESC 'object class' MUST ( salaryBASIC $ salaryDA $ salaryHRA $ salaryAllowance $ salaryTotal) ) objectclass ( 1.3.6.1.4.1.15490.2.8 NAME 'objAcademic' DESC 'object class' SUP top STRUCTURAL MUST ( academicYear ) )

Sample LDIF File

This section gives sample ldif file for creating LDAP tree,

dn: o=college o: college objectclass: organization objectclass: objCollege objectclass: top Description: top object class collegeName: ABC Engineering college collegePrincipal: John Peter collegePresident: Samual A collegeSecretary: Benson K collegeBoardMember: Jennifer King collegeBoardMember: George K Danial

dn: deptName=Civil,o=college deptName: Civil objectclass: objDepartment objectclass: top deptHead: abc

dn: deptName=Electronics,o=college deptName: Civil objectclass: objDepartment objectclass: top deptHead=defg

dn: branchName=ECE,deptName=Electronics,o=college branchName: ECE objectclass: top objectclass: objBranch branchHead: kkk branchNumberOfStudents: 50

dn: ou=student,branchName=ECE, deptName=Electronics,o=college ou: student objectclass: top objectclass: organizationalUnit

dn: ou=staff,branchName=ECE, deptName=Electronics,o=college ou: staff objectclass: top objectclass: organizationalUnit

dn: academicYear=1999-2000,ou=student,branchName=ECE, deptName=Electronics,o=college academicYear: 1999-2000 objectclass: top objectclass: objAcademic

dn: academicYear=2000-2001,ou=student,branchName=ECE, deptName=Electronics,o=college academicYear: 2000-2001 objectclass: top objectclass: objAcademic

dn: studentNumber=100,academicYear=1999-2000,ou=student,branchName=ECE, deptName=Electronics,o=college studentNumber: 100 objectclass: top objectclass: objStudent studentName: abc studentAddress: abc studentAcademicYear: 1999-2000 studentCourse: BS studentStatus: Active studentYear: 1999

dn: studentNumber=101,academicYear=1999-2000,ou=student,branchName=ECE, deptName=Electronics,o=college studentNumber: 101 objectclass: top objectclass: objStudent studentName: def studentAddress: def studentAcademicYear: 1999-2000 studentCourse: BS studentStatus: Active studentYear: 1999

dn: subjectCode=001,studentNumber=101,academicYear=1999-2000,ou=student,branchName=ECE, deptName=Electronics,o=college subjectCode: 001 objectclass: top objectclass: objSubject subjectName: Mathematics-1 subjectMarks: 90

dn: subjectCode=002,studentNumber=101,academicYear=1999-2000,ou=student,branchName=ECE, deptName=Electronics,o=college subjectCode: 002 objectclass: top objectclass: objSubject subjectName: Electrical Technology subjectMarks: 85

dn: ou=teaching,ou=staff,branchName=ECE, deptName=Electronics,o=college ou: teaching objectclass: top objectclass: organizationalUnit

dn: ou=nonteaching,ou=staff,branchName=ECE, deptName=Electronics,o=college ou: nonteaching objectclass: top objectclass: organizationalUnit

dn: staffID=001,ou=teaching,ou=staff,branchName=ECE, deptName=Electronics,o=college staffID: 001 objectclass: top objectclass: objStaff staffName: abc

staffAddress: sdflasjflasd staffQualification: MS, Phd staffDepartment: Electronics staffBranch: ECE staffType: teaching

dn: staffID=002,ou=teaching,ou=staff,branchName=ECE, deptName=Electronics,o=college staffID: 002 objectclass: top objectclass: objStaff staffName: def staffAddress: saas staffQualification: MS, Phd staffDepartment: Electronics staffBranch: ECE staffType: teaching

dn: staffID=101,ou=nonteaching,ou=staff,branchName=ECE, deptName=Electronics,o=college staffID: 101 objectclass: top objectclass: objStaff staffName: abc staffAddress: sdflasjflasd staffQualification: BS staffDepartment: Electronics staffBranch: ECE staffType: nonteaching

dn: staffID=102,ou=nonteaching,ou=staff,branchName=ECE, deptName=Electronics,o=college staffID: 102 objectclass: top objectclass: objStaff staffName: def staffAddress: saas staffQualification: B.Com staffDepartment: Electronics staffBranch: ECE staffType: nonteaching

dn: ou=Salary Details,staffID=002,ou=teaching,ou=staff,branchName=ECE, deptName=Electronics,o=college ou: Salary Details objectclass: top objectclass: objSalary objectclass: organizationalUnit salaryBasic: 10000 salaryDA: 20000 salaryHRA: 4000 salaryAllowance: 6000 salaryTotal: 40000

dn: subjectCode=001,staffID=002,ou=teaching,ou=staff,branchName=ECE, deptName=Electronics,o=college subjectCode: 001 objectclass: top objectclass: objSubject subjectName: Electrinics-1 subjectMarks: 100

dn: ou=Salary Details,staffID=102,ou=nonteaching,ou=staff,branchName=ECE, deptName=Electronics,o=college ou: Salary Details objectclass: top objectclass: objSalary objectclass: organizatinalUnit salaryBasic: 1000 salaryDA: 2000 salaryHRA: 400 salaryAllowance: 600 salaryTotal: 4000

LDAP

Use ApacheDS server for the LDAP server. Designing an LDAP application. Install the LDAP Server. Install the LDAP client Browser. The default Bind DN uid=admin,ou=system and password secret Edit the password if needed. Create the Root Suffix or the new Partion. Objects A directory service is an extension of a naming service. In a directory service, an object is also associated with a name. However, each object is allowed to have attributes. You can look up an object by its name; but you can also obtain the object's attributes or search for the object based on its attributes. The object classes for all objects in the directory form a class hierarchy. The classes "top" and "alias" are at the root of the hierarchy. For example, the "organizationalPerson" object class is a subclass of the "Person" object class, which in turn is a subclass of "top". When creating a new LDAP entry, you must always specify all of the object classes to which the new entry belongs. Because many directories do not support object class subclassing, you also should always include all of the superclasses of the entry. For example, for an "organizationalPerson" object, you should list in its object classes the "organizationalPerson", "person", and "top" classes. Add the Attributes. An attribute of a directory object is a property of the object. For example, a person can have the following attributes: last name, first name, user name, email address, telephone number, and so on. A printer can have attributes like resolution, color, and speed. An attribute has an identifier which is a unique name in that object. Each attribute can have one or more values. For instance, a person object can have an attribute called LastName. LastName is the identifier of an attribute. An attribute value is the content of the attribute. For example, the LastName attribute can have a value like "Martin". Define the Tree. Write the Search and browse application. Reference http://java.sun.com/products/jndi/tutorial/ldap/schema/object.html First Steps in LDAP I want to have a simple addressbook with telephonenumbers and email-addresses to be reached from every mail-client I use. The addressbook shall be built and modified automatically from a database which is the main datasource. * Structure * Preparing LDAP-server * Creating Organization Units * Create people in ou=people,dc=zirndorf,dc=de * Commands to delete and modify records * Query the LDAP-database from your mailprogram, how to configure Structure Data must be structured for LDAP. Our internet-domain is zirndorf.de, so I use that. Under that there is a unit in which all the people are. simple_structure.gif Preparing LDAP-server I use Debian-Linux for the LDAP-server and install this packages:slapd, ldap-utils. Take care that these files get installed in /etc/ldap/schema/: * core.schema * cosine.schema * inetorgperson.schema * nis.schema Now I have to modify the file /etc/ldap/sladp.conf: # Schema and objectClass definitions include /etc/ldap/schema/core.schema include /etc/ldap/schema/cosine.schema include /etc/ldap/schema/nis.schema include /etc/ldap/schema/inetorgperson.schema ... # The base of your directory suffix "dc=zirndorf,dc=de" rootdn "cn=admin,dc=zirndorf,dc=de" # this really means, that the password is "secret" rootpw secret # you can create a crypted password like this: slappasswd -u # and get the crypted version on your terminal: # rootpw {SSHA}8e8vfyo0KSWoLbyPVIPaG+MqH6h51Vst The server should listen only to a special IP-address (slapd is running under vserver-Linux) so I have to start the server like this in the start scripts: /usr/sbin/slapd -h ldap://10.1.1.138:389/ Starting LDAP (and checking bind with "netstat -ln" if you like). Creating Organization Units Create a file ou_people.ldif like this: # file ou_people.ldif dn: ou=people,dc=zirndorf,dc=de ou: people objectClass: top objectClass: organizationalUnit and import it into the database # ldapadd -a -x \ -D "cn=admin,dc=zirndorf,dc=de" -w secret \ -h ldap.zdf \ -f /tmp/ou_people.ldif Did the import work? You can dump your whole LDAP-server with this command to check it: # ldapsearch -x -b 'dc=zirndorf,dc=de' 'objectclass=*' -h ldap.zdf ... dn: ou=people,dc=zirndorf,dc=de ou: people objectClass: top objectClass: organizationalUnit ... If you have more units like this create more line in ou_people.ldif, some copy the lines I gave you. Create people in ou=people,dc=zirndorf,dc=de First create a very simple file to import into LDAP. I did this with Perl from a centralized database where I have all the informations collected: # the unique name in the directory dn: cn=Roland Wende, ou=people, dc=zirndorf, dc=de ou: people # which schemas to use objectClass: top objectClass: person objectClass: organizationalPerson objectClass: inetOrgPerson # the data itself, name-data cn: Roland Wende gn: Roland sn: Wende # other data (could be more, but doesn't have to be more) mail: roland.wende@zirndorf.de telephoneNumber: 9600-190 Now let's create a person with more attributes: # the unique name in the directory dn: cn=Richard Lippmann,ou=people,dc=zirndorf,dc=de # which schema to use objectClass: top objectClass: person objectClass: organizationalPerson objectClass: inetOrgPerson cn: Richard Lippmann givenName: Richard sn: Lippmann # internet section mail: lippmann@zirndorf.de mail: horshack@lisa.franken.de # address section, private postalAddress: My Way 5 postalCode: 90522 l: Oberasbach # phone section homePhone: 0911 /123 456 789 mobile: 0179 / 123 123 123 Commands to delete and modify records To delete a record this you have to know the dn (unique record-identifier): # ldapdelete -x \ -D "cn=admin,dc=zirndorf,dc=de" -w secret \ -h ldap.zdf \ 'cn=Roland Wende,ou=People,dc=zirndorf,dc=de' Recursively delete: ldapdelete -r ... If you want to modify a record you have to modify it completely. ALL the attributes must be in your ldif-file! # ldapmodify -x \ -D "cn=admin,dc=zirndorf,dc=de" -w secret \ -h ldap.zdf \ -f /tmp/ou_people.ldif Query the LDAP-database from your mailprogram, how to configure You have to know: * your LDAP-server's hostname (ldap.zdf) * your base-DSN (dc=zirndorf,dc=de) * Port (389 for cleartext)

Monday, July 23, 2007

vi Set number and copy line between number

:set number copy lines from address to destination. eg. :1,10co50 copy lines 1 to to 10 to below line 50

Monitor a log file in linux

tail -f /var/log/somelogfile.log This will show the last entry in the log file as updated.

Extracting gz file

tar xvfz filename.tar.gz

Thursday, July 19, 2007

Linux Networking

Network not connecting using wired network (lo) When you switch between the networks like home to office. The dns setting remains unchanged sometimes and this makes the network not to connect. Change the dns setting by ./network-admin go to the dns setting and under the search domain add the dns of the ISP(parent network) then issue the ./etc/init.d/networking restart. give a ping to google.com. If the packet are not lost you are good to go. There is another way you can prepend the new domain name in the /etc/dhcp3/dhcpclient.con file. open vi /s prepend and add the new dhcp domain name there .example "mydomain.com,"; This will make new domain available during each network startup