LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Populating an LDIF File (https://www.linuxquestions.org/questions/linux-newbie-8/populating-an-ldif-file-4175453481/)

newphoenixlinux 03-10-2013 03:26 AM

Creating an LDIF File
 
Hello,

I am setting up OpenLDAP and am using the instructions located here:

https://help.ubuntu.com/12.10/server...ap-server.html

One of the steps Modifying/Populating your Database says to:

Create the following LDIF file and call it add_content.ldif:

Is there a specific way to create it? Do you just go in and create a file using the TOUCH command and name it add_content.ldif and modify it with the data that goes into it? Or is there a specific program you should use to create the LDIF file.

Just want to make sure I do it correctly.

druuna 03-10-2013 03:40 AM

Ldif files are ordinary text files and you can use any text editor (vi, emacs and gedit are 3, there are many more) to create them.

There are programs available that are ldap specific and you can also use those to create ldif files, but I would keep it simple for now and use a normal text editor.

newphoenixlinux 03-10-2013 04:56 AM

Populating an LDIF File
 
Hello,
I am following the guide https://help.ubuntu.com/12.10/server...ap-server.html for installing and setting up OpenLDAP and wanted to get clarification on something in the section titled:

Modifying/Populating your Database

In the first part I pasted below it says:

Let's introduce some content to our database. We will add the following:

a node called People (to store users)

a node called Groups (to store groups)

a group called miners

a user called john

Create the following LDIF file and call it add_content.ldif:

dn: ou=People,dc=example,dc=com
objectClass: organizationalUnit
ou: People

dn: ou=Groups,dc=example,dc=com
objectClass: organizationalUnit
ou: Groups

dn: cn=miners,ou=Groups,dc=example,dc=com
objectClass: posixGroup
cn: miners
gidNumber: 5000

dn: uid=john,ou=People,dc=example,dc=com
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: shadowAccount
uid: john
sn: Doe
givenName: John
cn: John Doe
displayName: John Doe
uidNumber: 10000
gidNumber: 5000
userPassword: johnldap
gecos: John Doe
loginShell: /bin/bash
homeDirectory: /home/john

It's important that uid and gid values in your directory do not collide with local values. Use high number ranges, such as starting at 5000. By setting the uid and gid values in ldap high, you also allow for easier control of what can be done with a local user vs a ldap one. More on that later.

Add the content:

ldapadd -x -D cn=admin,dc=example,dc=com -W -f add_content.ldif

Enter LDAP Password: ********
adding new entry "ou=People,dc=example,dc=com"

adding new entry "ou=Groups,dc=example,dc=com"

adding new entry "cn=miners,ou=Groups,dc=example,dc=com"

adding new entry "uid=john,ou=People,dc=example,dc=com"

My question is, the first part that I have bolded and underlined says to create the file add_content.ldif and then shows a bunch of info, then the next part that I have bolded and underlined says add the content. Am I suppose to add the info from the first area in or the info from the second area into the add_content.ldif or do both sections get added into the one file. Or do you create 2 different files.

Just confused me

druuna 03-10-2013 05:10 AM

The first part creates a file that is used by ldapadd (the second part).

Using an input file (add_content.ldif in this case) when executing ldapadd makes life easier. ldapadd doesn't need an input file (you can enter all the entries by hand if you want/need to), but unless you are adding one specific entry I would advise against that.

In short:
- Create add_content.ldif as shown using a text editor,
- Execute the ldapadd command shown (which uses add_content.ldif).

PS: Do have a look at the manual pages.

colucix 03-10-2013 05:36 AM

Moderator note: two different threads on the same topic have been merged here.

newphoenixlinux 03-10-2013 06:15 AM

sounds good thanks for helping me with that. Also when the add_content.ldif is created where should it be saved to?

druuna 03-10-2013 06:51 AM

Quote:

Originally Posted by newphoenixlinux (Post 4908449)
Also when the add_content.ldif is created where should it be saved to?

You can store them wherever you want.

If you do want to keep these files I would suggest creating a separate directory (example name: ldifs) and store them there. Especially when you are new to this it might be a good idea to keep these ldif files around.

If you get more familiar with ldap you will notice that you do not need these files once you used them (there are possible exceptions, but lets not go into those right now).


All times are GMT -5. The time now is 06:54 PM.