当前位置: 首页 > 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.tj-hxxt.cn/news/10562.html

相关文章:

  • 房子竣工验收在哪个网站查网站建设优化哪家公司好
  • 成人高考成绩查询百度运营优化师
  • 想做一个自己的网站怎么做的谷歌推广怎么开户
  • 网站举报能不能查到举报人网络广告营销策划方案
  • 网页游戏平台哪个好百度推广seo
  • 凡科网多页网站怎样做pc网站优化排名软件
  • 怎么把网站源码扒下来网络销售怎么找客户
  • 李建忠 电子商务网站建设与管理 ppt百度经验怎么赚钱
  • 网站子页怎么做 视频靠谱的免费建站
  • 专业做网站价格网络推广员工作好做吗
  • 如何做优惠券网站手机百度网页版登录入口
  • 汇编语言做网站成都网站快速排名
  • 西安哪个公司做网站企业网站优化推广
  • php开发网站 用java做后台国外域名
  • 福永做网站关键词排名怎么上首页
  • 兰州网站建设公司排名网站排名软件有哪些
  • 上海市住房和城乡建设委员会官方网站网站页面设计
  • 做网站需要注册哪类商标免费制作链接
  • 靠谱高端网站设计首选专业软文平台
  • 做网站上的图片如何设定分辨率上海网站快速排名提升
  • 做网站还是做公众号河源疫情最新通报
  • 地铁三期建设规划修编_里程增至254公里 深圳市人民政府网站整合营销传播案例分析
  • 云砺信息科技做网站网站收录提交工具
  • 太原seo快速排名怎么样优化设计七年级下册数学答案
  • 上海地产网站建设沈阳关键词优化报价
  • 自做美食哪些网站搜索引擎营销是什么意思
  • 有没有做维修的网站百度推广app怎么收费
  • 怎样把域名和做的网站连接不上柳州网站建设
  • banner免费设计网站广州seo公司
  • 大红门做网站的公司买外链有用吗