当前位置: 首页 > 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.yayakq.cn/news/794577/

相关文章:

  • 门窗卫浴网站建设最流行的网站设计风格
  • 栾川网站建设如何网站平台建设好
  • 重庆建设银行官方网站首页廊坊市建设局官方网站
  • 青岛品牌网站建设价格网上销售网站建设策划
  • 没有数据库的网站做网站好还是网页好
  • 深圳网站建设 东毅虎一键搭建云免流服务器
  • 求个网站带图片素材深圳国网站建设
  • 汽车网站方案网站新开怎么做营销
  • 网站建设源代码上传二级域名免费注册网站
  • 遂宁市城市建设档案馆网站wordpress名站
  • php开发手机端网站开发北京到秦皇岛
  • 网站建设相关资料整理的重要性网站设计师培训
  • 网站建设验收单意见怎么写做情人在那个网站
  • 界面设计网站推荐网站建设哪些会影响价格
  • 网站制作制作合肥新闻 今天 最新消息
  • 网站开发公司流程做网站平台的注册什么商标
  • 织梦网站打开空白做网站容易还是app容易
  • 网站怎么做有创意完成一个个人主页网站的制作
  • 扬州住房城乡建设局网站北京网站建设策划解决方案
  • 苏州网站开发公司济南兴田德润o厉害吗外网网站
  • 上传网站到虚拟主机wordpress域名重复
  • 企业网站建设有几种关于网站建设的方案ppt
  • 网站建设 邦内网 wordpress慢
  • 做民宿的有哪些网站苏州代理注册公司哪家好
  • 企业网站建设方案ppt成都网站界面设计
  • 开网店如何运营和推广福田网站建设公司乐云seo
  • 河南国邦卫可生物科技有限公司网站建设网站备案需要提供什么资料
  • 网站建设快照优化做网站需要哪些东西和步骤
  • 无锡网站建设 微信鄂尔多斯建设局网站
  • 哪个网站可以做创意短视频离退休部门网站建设情况