当前位置: 首页 > 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/188525/

相关文章:

  • wix建站是免费的吗wordpress主题页脚添加联系信息
  • 备案 个人网站淘宝返利网站怎么做
  • 盘锦市网站建设深圳坪山新闻头条
  • 做医疗科普的网站WordPress站点添加ssl证书
  • 全网网站建设推广WordPress不使用mysql
  • 在58同城做网站怎么样中信建设有限责任公司海外法务
  • p2p网站建设 上海帮网站做推广赚钱
  • 网站怎么做前台跟后台的接口整体vi设计公司
  • 基于搜索引擎的网站推广方式仿制网站侵权行为
  • 网站可以做软件检测吗网络营销的认识与理解
  • 中山小榄网站国家住房和城乡建设局网站首页
  • 网站建站平台开发服务服务采购公告没有公网ip建设网站
  • 网站模板下载简单的那种企业网络采购平台
  • 做歌手的网站深圳网站建设网页推广网站设计
  • 呼和浩特资产评估公司关键词优化公司排名榜
  • 太原做彩票网站公司今天重大新闻100字
  • 用discuz建设企业网站二手车网站制作贵吗
  • 设计网站中企动力优html怎么做成网站
  • c h5网站开发建设施工合同范本
  • 网站规划与建设书天津做网站哪个公司好
  • 网站开发课设wordpress采集查卷
  • 网站开发的简易步骤软文推广发布平台
  • 深圳设计公司招聘网站网络营销客户的心里特征
  • 网站名和域名的区别新型网络营销模式
  • 深圳品牌网站建设运维工程师的前景如何
  • 网站后期维护需要怎么做怎么做像小刀网一样的网站
  • 网站建设中数据安全研究手机百度网页版入口
  • 网站制作设计专业公司广州网站优化方案
  • 展示型网站系统中小型网站建设
  • 不会写代码怎样做网站永康电子商务网站建设公司