osixia / docker-openldap

OpenLDAP container image 🐳🌴
MIT License
4.05k stars 977 forks source link

Add to README.md insturctions for adding custom schema #177

Open mzayikin opened 6 years ago

mzayikin commented 6 years ago

I have mySchema.schema which has this definition

attributetype ( 2.16.840.1.113734.3.1.1
    NAME 'spid'
    DESC 'Service provider ID'
    EQUALITY caseIgnoreMatch
    SUBSTR caseIgnoreSubstringsMatch
    SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )

so on container start

docker run --env LDAP_ADMIN_PASSWORD="mypass" --env LDAP_DOMAIN="example.com" --env LDAP_TLS=false --name=my-ldap --volume /Users/me/LDAP/data:/container/service/slapd/assets/config/bootstrap/ldif/custom osixia/openldap:1.1.10 --copy-service --loglevel debug

I get this error

ldap_add: Undefined attribute type (17)
    additional info: spid: attribute type undefined

my data folder /Users/me/LDAP/data does have schema definition and yes, I have tried to mount it to different places. Could you please add more information about mounting schema file to container?

Thanks in advance, Michael

giafar commented 6 years ago

Hi Michael, create a .schema file and put in then /container/service/slapd/assets/config/bootstrap/schema. The startup script will create the ldif for you and add to the server schema files.

This is my working schema file (spid.schema).

attributetype ( 2.25.1 NAME 'spidCode' DESC 'SPID - Spid Code' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} ) objectclass ( 2.25 NAME 'spidPerson' DESC '' SUP inetOrgPerson STRUCTURAL MUST ( spidCode ) )

Please reneame the file in my.schema because the Schema name part is offending some startup script.

Regards Gianluca.

secsea commented 6 years ago

hello, i have a .schema file named my.schema in docker host /mnt/ldap-docker/schema/

` attributetype ( 2.16.840.1.113730.3.1.901 NAME 'userType' DESC 'type of user' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )

objectclass ( 2.16.840.1.113730.3.2.2 NAME 'inetOrgPerson' DESC 'RFC2798: Internet Organizational Person' SUP organizationalPerson STRUCTURAL MAY ( userType ) ) `

i run ldap with

docker run --env LDAP_ORGANISATION="myconpany" --env LDAP_DOMAIN="myconpany.com" \ --env LDAP_ADMIN_PASSWORD="admin321" \ -p 389:389 -p 636:636 \ --volume /mnt/ldap-docker/database:/var/lib/ldap \ --volume /mnt/ldap-docker/config:/etc/ldap/slapd.d \ --volume /mnt/ldap-docker/schema/my.schema:/container/service/slapd/assets/config/bootstrap/schema/my.schema \ --detach osixia/openldap:1.1.11 --copy-service

i still cannot add attribute userType for a user Undefined attribute type (17) userType attribute type undefined

Is there anything wrong with me?

hpwxf commented 6 years ago

As written in image/service/slapd/startup.sh (follow $BOOTSTRAP variable), *.schema files from /container/service/slapd/assets/config/bootstrap/schema directory are loaded (after a schema-to-ldif.sh conversion) only if database and config directories are empty.

As I had to start a new ldap service, I have restarted the container from a fresh clean data/config volumes and thus my schema has been loaded.