当前位置: 首页 > news >正文

广州做包包的网站昆明优化网站多少钱

广州做包包的网站,昆明优化网站多少钱,网站备案是否收费,做虚拟货币交易网站1.Ldap介绍 LDAP#xff0c;Lightweight Directory Access Protocol#xff0c;轻量级目录访问协议. LDAP是一种特殊的服务器#xff0c;可以存储数据数据的存储是目录形式的#xff0c;或者可以理解为树状结构#xff08;一层套一层#xff09;一般存储关于用户、用户…1.Ldap介绍 LDAPLightweight Directory Access Protocol轻量级目录访问协议. LDAP是一种特殊的服务器可以存储数据数据的存储是目录形式的或者可以理解为树状结构一层套一层一般存储关于用户、用户认证信息、组、用户成员通常用于用户认证与授权 LDAP简称对应 oorganization组织-公司ouorganization unit组织单元-部门ccountryName国家dcdomainComponent域名snsurname姓氏cncommon name常用名称 2.环境搭建 docker-compose-ldap.yaml version: 3services:openldap:container_name: openldapimage: osixia/openldap:latestports:- 8389:389- 8636:636volumes:- ~/ldap/backup:/data/backup- ~/ldap/data:/var/lib/openldap- ~/ldap/config:/etc/openldap/slapd.d- ~/ldap/certs:/assets/slapd/certscommand: [--copy-service, --loglevel, debug]phpldapadmin:container_name: phpldapadminimage: osixia/phpldapadmin:latestports:- 8080:80environment:- PHPLDAPADMIN_HTTPSfalse- PHPLDAPADMIN_LDAP_HOSTSopenldaplinks:- openldapdepends_on:- openldap ldap setup docker-compose -f docker-compose-ldap.yml -p ldap up -dopen http://localhost:8080/ default account usernamecnadmin,dcexample,dcorg passwordadmin init data dn: oupeople,dcexapmple,dcorg objectClass: top objectClass: organizationalUnit ou: people 3.代码工程 pom.xml ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdparentartifactIdspringboot-demo/artifactIdgroupIdcom.et/groupIdversion1.0-SNAPSHOT/version/parentmodelVersion4.0.0/modelVersionartifactIdldap/artifactIdpropertiesmaven.compiler.source8/maven.compiler.sourcemaven.compiler.target8/maven.compiler.target/propertiesdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-autoconfigure/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependency!--ldap--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-data-ldap/artifactId/dependencydependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactId/dependency/dependencies /project application.yaml spring:application:name: spring-demo-ldap# ldap configurationldap:urls: ldap://127.0.0.1:8389base: dcexample,dcorgusername: cnadmin,${spring.ldap.base}password: adminserver:port: 8088 Person.java package com.et.ldap.entity;import lombok.Data; import org.springframework.ldap.odm.annotations.Attribute; import org.springframework.ldap.odm.annotations.DnAttribute; import org.springframework.ldap.odm.annotations.Entry; import org.springframework.ldap.odm.annotations.Id;import javax.naming.Name; import java.io.Serializable;Data Entry(base oupeople, objectClassesinetOrgPerson) public class Person implements Serializable {private static final long serialVersionUID -337113594734127702L;/***neccesary*/Idprivate Name id;DnAttribute(value uid, index 3)private String uid;Attribute(name cn)private String commonName;Attribute(name sn)private String suerName;private String userPassword;} 以上只是一些关键代码所有代码请参见下面代码仓库 代码仓库 https://github.com/Harries/springboot-demo 4.测试 package com.et.ldap;import com.et.ldap.entity.Person; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.ldap.NamingException; import org.springframework.ldap.core.AttributesMapper; import org.springframework.ldap.core.LdapTemplate; import org.springframework.test.context.junit4.SpringRunner;import javax.naming.NamingEnumeration; import javax.naming.directory.Attribute; import javax.naming.directory.Attributes; import java.util.List;import static org.springframework.ldap.query.LdapQueryBuilder.query;RunWith(SpringRunner.class) SpringBootTest public class ApplicationTests {Autowiredprivate LdapTemplate ldapTemplate;/*** add person*/Testpublic void addPerson() {Person person new Person();person.setUid(uid:14);person.setSuerName(LISI);person.setCommonName(lisi);person.setUserPassword(123456);ldapTemplate.create(person);}/*** filter search*/Testpublic void filterSearch() {// Get the domain list. If you want to get a certain domain, the filter can be written like this: ((objectclassdcObject)(dcexample))// String filter ((objectclassdcObject));// Get the list of organizations. If you want to get a specific organization, the filter can be written like this: ((objectclassorganizationalUnit)(oupeople)// String filter ((objectclassorganizationalUnit));//Get the people list. If you want to get a certain person, the filter can be written like this: ((objectclassinetOrgPerson)(uiduid:13))String filter ((objectclassinetOrgPerson));ListPerson list ldapTemplate.search(, filter, new AttributesMapper() {Overridepublic Object mapFromAttributes(Attributes attributes) throws NamingException, javax.naming.NamingException {//如果不知道ldap中有哪些属性可以使用下面这种方式打印NamingEnumeration? extends Attribute att attributes.getAll();while (att.hasMore()) {Attribute a att.next();System.out.println(a.getID() a.get());}Person p new Person();Attribute a attributes.get(cn);if (a ! null) p.setCommonName((String) a.get());a attributes.get(uid);if (a ! null) p.setUid((String) a.get());a attributes.get(sn);if (a ! null) p.setSuerName((String) a.get());a attributes.get(userPassword);if (a ! null) p.setUserPassword(a.get().toString());return p;}});list.stream().forEach(System.out::println);}/*** query search*/Testpublic void querySearch() {// You can also use filter query method, filter is ((objectClassuser)(!(objectClasscomputer))ListPerson personList ldapTemplate.search(query().where(objectClass).is(inetOrgPerson).and(uid).is(uid:14),new AttributesMapper() {Overridepublic Person mapFromAttributes(Attributes attributes) throws NamingException, javax.naming.NamingException {//If you don’t know what attributes are in ldap, you can print them in the following way// NamingEnumeration? extends Attribute att attr.getAll();//while (att.hasMore()) {// Attribute a att.next();// System.out.println(a.getID());//}Person p new Person();Attribute a attributes.get(cn);if (a ! null) p.setCommonName((String) a.get());a attributes.get(uid);if (a ! null) p.setUid((String) a.get());a attributes.get(sn);if (a ! null) p.setSuerName((String) a.get());a attributes.get(userPassword);if (a ! null) p.setUserPassword(a.get().toString());return p;}});personList.stream().forEach(System.out::println);} } 运行单元测试类查看数据可以看到新增一个人 5.引用参考 Spring Boot集成Ldap快速入门Demo | Harries Blog™Getting Started | Authenticating a User with LDAPDocker安装LDAP并集成Springboot测试LDAP_ladp dockers-CSDN博客
http://www.ho-use.cn/article/10820030.html

相关文章:

  • 樟木头镇仿做网站简约 网站 设计
  • 旅游网站建设的技术可行性有网络网站打不开怎么回事
  • 做网站去哪里找网站怎么优化推荐
  • 企业网站设计模板陕西企尚网络科技有限公司
  • 郑州工程建设信息网站团关系转接网站建设
  • 太湖云建站网站建设阿里巴巴国际站运营培训
  • 素材下载网站源码小红书kol推广
  • 网站首页被k咋办wordpress建网站知乎
  • 网站建设gzdlzgg平台怎么推广
  • 网站怎么做留言提交功能广告设计网站排行榜前十名有哪些
  • 不同性质网站郑州网站建设求职简历
  • 课程网站建设技术施工企业市场调查目的与主题主要有()。
  • 网站精简布局wordpress安装主题后没内容
  • 建设机械网站制作谷歌seo
  • 网站建设基本流程前期黔东南州两学一做教育网站
  • 网站做百度竞价利于百度优化为什么需要响应式网站
  • 做网站的公司叫什么wordpress主板不显示内容
  • 国内人做韩国网站一般都卖什么手续专门做水产海鲜的网站吗
  • 个人网站制作步骤网站怎么维护
  • 网站建设电脑ps如何做网页设计
  • 徐州网站公司研发网站要多长时间
  • 展览馆网站建设方案书沃尔玛网上商城中国
  • 沈阳软件公司 网站制作深圳企业社保登录入口
  • 韶关建网站怎样建立个人网络平台
  • 军用棉被门网站建设网站建设需要哪些证
  • 手机交互设计网站wordpress 新编辑器
  • 企业网站网页网页代码编辑器有哪些软件
  • 安徽网站建设合肥网站建设郑州住房城乡建设官网
  • 网站建设过程发生的费用如何提升网站流量
  • 枫泾网站建设展馆设计的主题有哪些