zoukankan      html  css  js  c++  java
  • openldap小结

    1. 下载spring-ldap-1.3.0.RELEASE-with-dependencies.zip,里面doc,demo很全面,jar基本满足要求。

    2. 附带的junit的test还是别运行了,跑好累了都不动。

    3. demo中附带了samplesdemosdemo-tigersrc est esourcesconfigsetup_data.ldif,可直接放入BDB。但放入前需先建立根节点,例如可使用下列代码建立:

    dn: dc=jayway,dc=se
    objectclass: dcObject
    objectclass: organization
    o: Example Company
    dc: jayway
    
    dn: cn=root,dc=jayway,dc=se
    objectclass: organizationalRole
    cn: root
    

    4. 对象中存在外键的概念,假如有一复合对象,若想为对象属性赋值,不必须先建立此属性的对象。

    dn: c=Sweden,dc=jayway,dc=se
    objectclass: top
    objectclass: country
    c: Sweden
    description: The country of Sweden
    
    dn: ou=company1,c=Sweden,dc=jayway,dc=se
    objectclass: top
    objectclass: organizationalUnit
    ou: company1
    description: First company in Sweden
    

    ou=company1,c=Sweden,dc=jayway,dc=se对象建立前,c=Sweden必须先建立好。在java中对象亦如此。

    package org.springframework.ldap.demo.dao;
    
    import java.util.List;
    
    import org.springframework.ldap.demo.domain.Person;
    
    public class Test {
    
        PersonDaoImpl dao = new PersonDaoImpl();
    
        public Test() {
            super();
            init();
        }
    
        public final void init() {
            dao.setBase("dc=jayway,dc=se");
            dao.setPassword("secret");
            dao.setUrl("ldap://localhost/");
            dao.setUserDn("cn=root,dc=jayway,dc=se");
        }
    
        public static void main(String[] args) {
            Test test = new Test();
            List<String> names = test.dao.getAllPersonNames();
            for (String name : names) {
                System.out.println(name);
            }
            Person person = test.dao.findByPrimaryKey("Sweden", "company1",
                    "Sam Tsui");
            person.setDescription("我靠");
            test.dao.update(person);
            System.out.println(person);
        }
    
        public void addPerson() {
            Person person = new Person();
            person.setCompany("company1");
            person.setCountry("Sweden");
            person.setDescription("Power Charge.");
            person.setFullName("Sam Tsui");
            person.setLastName("Tsui");
            person.setPhone("12345");
            dao.create(person);
        }
    
        public void deletePerson() {
            Person person = new Person();
            person.setCompany("company1");
            person.setCountry("Sweden");
            person.setFullName("Sam Tsui");
            dao.delete(person);
        }
    }
  • 相关阅读:
    致命错误 RC1121: RC : fatal error RC1121 : I/O error reading file
    Windows 右键 添加 “使用CMD打开”
    C2061: syntax error : identifier &apos;THIS_FILE&apos;
    delphi 产生随机数
    使用Code::Blocks编译VC程序
    Delphi中用来截取字符的函数,以及使用方法
    VC6.0 最新的 SDK platform sdk xpsp2 官方下载地址
    ubuntu下codeblocks起步
    VC中Error spawning cl.exe错误的解决方法
    Delphi如何获取时间月份
  • 原文地址:https://www.cnblogs.com/xzs603/p/3166101.html
Copyright © 2011-2022 走看看