#yum install migrationtools -y
#vim /usr/share/migrationtools/migrate_common.ph
$DEFAULT_MAIL_DOMAIN = "liuyao.com";
$DEFAULT_BASE = "dc=liuyao,dc=com";
#/usr/share/migrationtools/migrate_base.pl > base.ldif
2.创建系统用户
#useradd liuyao
#passwd 我不告诉你
3.导出系统用户
#tail -n 1 /etc/passwd > liuyao_user
#tail -n 1 /etc/group > liuyao_group
4.转换为ldif格式
#/usr/share/migrationtools/migrate_passwd.pl liuyao_user liuyao_user.ldif
#/usr/share/migrationtools/migrate_group.pl liuyao_group liuyao_group.ldif
5. 导入到openldap里
#ldapadd -xWD "cn=root,dc=liuyao,dc=com" -f liuyao_user.ldif
#ldapadd -xWD "cn=root,dc=liuyao,dc=com" -f liuyao_group.ldif
需要输入密码的 密码就是之前设置的
6. 检查相关用户是否导入成功
#ldapsearch -LLL -x -D "cn=root,dc=liuyao,dc=com" -W -b "dc=liuyao,dc=com" "uid=liuyao"
Enter LDAP Password: 需要输入密码的 密码就是之前设置的
#返回结果如下
dn: uid=liuyao,ou=devops,dc=liuyao,dc=com
uid: liuyao
cn: liuyao
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword:: 我不告诉你
shadowLastChange: 17356
shadowMin: 0
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 500
gidNumber: 500
homeDirectory: /home/liuyao