• openldap 自行添加新的AttributeTypes和ObjectClasses


    openldap 自行添加新的AttributeTypes和ObjectClasses

    1.openldap添加AttributeType

    我的方式比较简单粗暴,是直接修改ldfi文件完成的,文件里面提示使用ldapmodify修改,但是我还没有尝试成功

    文件位置:/etc/openldap/slapd.d/cn=config/cn=schema,里面的文件在重启之后会自动的加载

    修改目标:为posixGroup添加一个新的属性leader

    所属文件名:cn={2}nis.ldif

    添加内容如下:

    ...

    olcAttributeTypes: {24}( 1.3.6.1.1.1.1.28 NAME 'leader' EQUALITY caseEx
    actIA5Match SUBSTR caseExactIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.
    121.1.26{1024} SINGLE-VALUE )

    ...

    olcObjectClasses: {2}( 1.3.6.1.1.1.2.2 NAME 'posixGroup' DESC 'Abstraction o
    f a group of accounts' SUP top STRUCTURAL MUST ( cn $ gidNumber ) MAY ( use
    rPassword $ memberUid $ description $ leader ) )

    ...

    然后重启ldap服务: service slapd restart

    查看属性是否已经生效

    sudo ldapsearch -Q -LLL -Y EXTERNAL -H ldapi:/// -b cn=schema,cn=config  

    显示较多,可以通过grep进行筛选

    PS:我遇到的一个问题是,我重启后从phpldapamin里面怎么都看不到,后来直接重启了nginx服务,才加载过来

    2.openldap 添加ObjectClass

    创建一个test.schema

    [root@localhost test]# cat test.schema
    attributetype ( 1.3.6.1.4.1.42.2.27.4.1.98
    NAME 'userCertNoBaixue'
    DESC 'userCertNoBaixue'
    EQUALITY caseExactMatch
    SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
    SINGLE-VALUE )
    attributetype ( 1.3.6.1.4.1.42.2.27.4.1.97
    NAME 'userCertCNBaixue'
    DESC 'userCertCNBaixue'
    EQUALITY caseExactMatch
    SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
    SINGLE-VALUE )
    objectclass ( 1.3.6.1.4.1.42.2.27.4.2.88
    NAME 'financeUser'
    DESC 'financeUser'
    SUP top
    AUXILIARY
    MAY ( cn $ userCertNoBaixue $ userCertCNBaixue ) )

    再创建一个cat test.conf

    [root@localhost test]# cat test.conf
    include /etc/openldap/test/test.schema

    两个文件放在同级目录,并在目录下创建一个testdir

    使用命令slaptest -f test.conf -F testdir

    将会在tesdir文件夹下生成多个文件

    在路径testdir/cn=config/cn=schema 将文件改名为ebankUser.ldif

    文件内容如下:

    [root@localhost cn=schema]# cat ebankUser.ldif
    # AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify.
    # CRC32 ded11f2d
    dn: cn=financeUser,cn=schema,cn=config
    objectClass: olcSchemaConfig
    cn: financeUser
    olcAttributeTypes: {0}( 1.3.6.1.4.1.42.2.27.4.1.98 NAME 'userCertNoBaixue' D
    ESC 'userCertNoBaixue' EQUALITY caseExactMatch SYNTAX 1.3.6.1.4.1.1466.115.
    121.1.15 SINGLE-VALUE )
    olcAttributeTypes: {1}( 1.3.6.1.4.1.42.2.27.4.1.97 NAME 'userCertCNBaixue' D
    ESC 'userCertCNBaixue' EQUALITY caseExactMatch SYNTAX 1.3.6.1.4.1.1466.115.
    121.1.15 SINGLE-VALUE )
    olcObjectClasses: {0}( 1.3.6.1.4.1.42.2.27.4.2.88 NAME 'financeUser' DESC 'f
    inanceUser' SUP top AUXILIARY MAY ( cn $ userCertNoBaixue $ userCertCNBaixu
    e ) )
    structuralObjectClass: olcSchemaConfig
    entryUUID: 12f670e2-a24e-103a-9fa1-f93b5ff9c79e
    creatorsName: cn=config
    createTimestamp: 20201014094753Z
    entryCSN: 20201014094753.348483Z#000000#000#000000
    modifiersName: cn=config
    modifyTimestamp: 20201014094753Z

    标红的位置是需要自己手动修改的

    最后使用如下命令添加:

    slapadd -l ebankUser.ldif -n 0

    会在/etc/openldap/slapd.d/cn=config/cn=schema看到cn={13}financeuser.ldif

    其余操作跟上面一样,重启后最好将nginx也重启了,确保生效

  • 相关阅读:
    ActiveSync合作关系对话框的配置
    WINCE对象存储区(object store)
    Wince 隐藏TASKBAR的方法
    Wince输入法换肤换语言机制
    poj 3080 Blue Jeans 解题报告
    codeforces A. Vasily the Bear and Triangle 解题报告
    hdu 1050 Moving Tables 解题报告
    hdu 1113 Word Amalgamation 解题报告
    codeforces A. IQ Test 解题报告
    poj 1007 DNA Sorting 解题报告
  • 原文地址:https://www.cnblogs.com/estherSH/p/13816907.html
Copyright © 2020-2023  润新知