Custom Search

Tuesday, September 28, 2010

openldap add new objectClass multiple attributetype

openldap add new objectClass multiple attributetype

1)
[root@localhost schema]# vim /etc/openldap/schema/new_attribute.schema
attributetype ( 1.3.6.1 <---------- Any unique number
NAME 'groupName'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )

[root@localhost schema]# vim /etc/openldap/schema/new_attribute.schema
attributetype ( 1.3.6.2 <---------- Any unique number
NAME 'roleName'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )

[root@localhost schema]# vim /etc/openldap/schema/new_attribute.schema
attributetype ( 1.3.6.3 <---------- Any unique number
NAME 'emailId'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )

2)
[root@localhost schema]# vim /etc/openldap/schema/new_object.schema
objectClass ( 1.3.6.1.4.1.4203.666.1.100 <--------- Any unique number
NAME 'MyCompany' <-----------
DESC 'MyCompany Description'
SUP inetOrgPerson
STRUCTURAL
MAY ( groupName, roleName, emailId $ c ) <---------
)


3)
[root@localhost openldap]# vim /etc/openldap/slapd.conf
#
# See slapd.conf(5) for details on configuration options.
# This file should NOT be world readable.
#
include /etc/openldap/schema/core.schema
include /etc/openldap/schema/cosine.schema
include /etc/openldap/schema/inetorgperson.schema
include /etc/openldap/schema/nis.schema

include /etc/openldap/schema/new_attribute.schema <---------
include /etc/openldap/schema/new_object.schema <----------- include order is important, first attribute then object


4)
[root@localhost openldap]# service ldap restart
Stopping slapd: [ OK ]
Checking configuration files for slapd: bdb_db_open: Warning - No DB_CONFIG file found in directory /var/lib/ldap: (2)
Expect poor performance for suffix dc=localhost,dc=localdomain.
config file testing succeeded
[ OK ]
Starting slapd: [ OK ]


5) vim /etc/openldap/user.ldif
dn: uid=smith,dc=localhost,dc=localdomain

objectclass: top
objectclass: person
objectclass: inetorgperson
objectclass: MyCompany <-------
cn: smith
groupName: adminGroup <--------
roleName: Operator <--------
emailId: myname@gmail.com <--------
uid: smith
userPassword: smith

[root@localhost openldap]# /usr/bin/ldapadd -x -D 'uid=root,dc=localhost,dc=localdomain' -W -f /etc/openldap/user.ldif
Enter LDAP Password:
adding new entry "uid=t1,dc=localhost,dc=localdomain"


*****************************

No comments:

Post a Comment