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

最好的机票网站建设百度搜索榜排名

最好的机票网站建设,百度搜索榜排名,自己电脑做主机怎么做网站,做游戏钓鱼网站目录 1.spring-ldap的pom依赖2.ldapTemplate的生成--方式1自动注入 2.1 spring-ldap声明2.2 ldapTemplate bean2.3 使用 3.ldapTemplate的生成--方式2代码生成4.spring-ldap的使用 正文 之前学习过spring-ldap的官方文档:2017.4.10 spring-ldap官方文档学习 现在是对…

 

正文

之前学习过spring-ldap的官方文档:2017.4.10 spring-ldap官方文档学习

现在是对实际使用的spring-ldap及使用过程中遇到的问题,进行总结。

 

回到顶部

1.spring-ldap的pom依赖

复制代码
         <!-- 添加Spring-ldap--><dependency><groupId>org.springframework.ldap</groupId><artifactId>spring-ldap-core</artifactId><version>2.3.1.RELEASE</version></dependency>
复制代码

 

下面的网址是spring的ldap页,里面有一个quick start。其中显示了spring-ldap最近的版本,并且勾选不同的版本,会自动生成依赖。

http://projects.spring.io/spring-ldap/

 

回到顶部

2.ldapTemplate的生成--方式1自动注入

2.1 spring-ldap声明
复制代码
 <beans xmlns="http://www.springframework.org/schema/beans"       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"      xmlns:ldap="http://www.springframework.org/schema/ldap"       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/ldap http://www.springframework.org/schema/ldap/spring-ldap.xsd">
复制代码

 

2.2 ldapTemplate bean
复制代码
 <context:property-placeholder location="classpath:/ldap.properties" />
<ldap:context-source id="contextSource" password="${sample.ldap.password}" url="${sample.ldap.url}" username="${sample.ldap.userDn}" base="${sample.ldap.base}" />
<ldap:ldap-template id="ldapTemplate" context-source-ref="contextSource"/>
复制代码

或者

复制代码
  <bean id="contextSource"    
      class="org.springframework.ldap.core.support.LdapContextSource">    
      <property name="url" value="${sample.ldap.url}" />    
      <property name="base" value="${sample.ldap.base}" />    
      <property name="userDn" value="${sample.ldap.userDn}" />    
      <property name="password" value="${sample.ldap.password}" />  
  </bean>  
    
  <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">    <constructor-arg ref="contextSource" />  </bean>
复制代码

 

2.3 使用
 @Autowired
 private LdapTemplate ldapTemplate;

 

回到顶部

3.ldapTemplate的生成--方式2代码生成

复制代码
  public LdapTemplate getLdapTemplate(){
          LdapTemplate template = null;
          try {
              LdapContextSource contextSource = new LdapContextSource();
              contextSource.setUrl(getSync_ldap_url());
              contextSource.setBase(getSync_ldap_base());
              contextSource.setUserDn(getSync_ldap_userDn());
              contextSource.setPassword(getSync_ldap_password());
              contextSource.setPooled(false);
             contextSource.afterPropertiesSet(); // importanttemplate = new LdapTemplate(contextSource);
         }catch (Exception e){
             e.printStackTrace();
         }
         return template;
     }
复制代码

 

回到顶部

4.spring-ldap的使用

api的使用在上次的文档中已经学习过了:2017.4.10 spring-ldap官方文档学习

一些简单示例:

复制代码
/*** 动态创建dn* @param user* @return*/private Name buildDn(User user) {return LdapNameBuilder.newInstance().add("ou", "Users").add("uid",user.getFdUserid().toString()).build();}/*** 在ldap里更新用户* @param user*/private void updateUser(User user) {Name dn = buildDn(user);getLdapTemplate().rebind(dn, null, buildAttributes(user));}/*** 在ldap里删除用户* @param user*/private void deleteUser(User user) {Name dn = buildDn(user);getLdapTemplate().unbind(dn);}/*** 在ldap里创建用户* @param user*/private void createUser(User user) {Name dn = buildDn(user);getLdapTemplate().bind(dn, null, buildAttributes(user));}/*** 动态构建属性* @param user* @return*/private Attributes buildAttributes(User user) {Attributes attrs = new BasicAttributes();try {BasicAttribute objectclass = new BasicAttribute("objectclass");objectclass.add("top");objectclass.add("posixAccount");objectclass.add("inetOrgPerson");attrs.put(objectclass);attrs.put("userPassword", user.getFdLdapPassword() == null ? "" : user.getFdLdapPassword());attrs.put("cn", user.getFdUsername() + "@" + user.getFdTenantName());attrs.put("sn", user.getFdUsername() + "@" + user.getFdTenantName());attrs.put("displayName", user.getFdDisplayName()== null? "":user.getFdDisplayName());attrs.put("homeDirectory", "/root");attrs.put("uidNumber", "0");attrs.put("uid", user.getFdUserid().toString());attrs.put("gidNumber", "0");}catch (Exception e){e.printStackTrace();}return attrs;}
复制代码
http://www.hkea.cn/news/261070/

相关文章:

  • 专业网站建设费用报价今日最新消息
  • 电商网站建设论文2022黄页全国各行业
  • 能源企业 网站建设网络营销的应用
  • 如何看网站是用什么语言做的关键词排名是由什么决定的
  • 政府网站建设招标书百度网站收录
  • 已经有了网站怎么做推广哈尔滨关键词优化报价
  • 网站建设与管理作业镇江推广公司
  • 域名申请好后 如何建设网站网站权重划分
  • 佛山百度网站快速优化网络营销推广工具
  • 建一个网站需要哪些人广州seo网站推广公司
  • 建设银行etc官方网站搜索引擎优化的七个步骤
  • 做网站需要花钱吗海南百度推广运营中心
  • 做的网站显示图片很慢百度运营公司
  • 青州哪里做网站公司推广渠道
  • 网站面包屑导航怎么做的网推接单平台有哪些
  • 宜昌网站建设兼职百度关键词排名软件
  • 如何让百度快照找到自己的网站营销策划方案ppt模板
  • php网站超市广告软文是什么意思
  • b2c跨境电商宣城网站seo
  • 网站建设一流公司免费网站开发平台
  • 网站开发模式名词外贸谷歌优化
  • 网站素材 下载产品推广渠道
  • 网站后台维护怎么做seo专员工资一般多少
  • 中国网站推广黄页名录微商推广哪家好
  • 哈尔滨网站开发电话电商培训基地
  • 如何用php数据库做网站搜索seo优化托管
  • 中国城乡建设部人力网站首页优化落实疫情防控
  • 做网站到底能不能赚钱网络优化工程师前景
  • 乌镇网站建设标书百度站长工具域名查询
  • 制作公司网站价格腾讯广告代理商加盟