コード例 #1
0
ファイル: ItimImpl.java プロジェクト: self-java/self-java
  public boolean ChangePassword(String uid, String newPwd) {
    try {
      // System.out.println("changePassword===mobile--="+mobile);

      Person person = getPerson(uid);
      if (person == null) {
        return false;
      }

      itimContext.login();
      PersonMO ownerMO =
          new PersonMO(
              itimContext.getPlatform(), itimContext.getSubject(), person.getDistinguishedName());

      PasswordManager pManager =
          new PasswordManager(itimContext.getPlatform(), itimContext.getSubject());
      Request request = pManager.synchPasswords(ownerMO, newPwd, null);

      /*
       */
      /** 为了解决TIM修改密码延时,以及TAMAgent有故障时新密码登陆问题, 在修改TIM的时候同时修改IDS密码 */
      /*
       * LdapImpl search = new LdapImpl(); boolean chids=
       * search.changePassword(mobile,newPwd); if(!chids){
       * System.out.println("----------------修改IDS密码失败-------------"+mobile); }
       */

      return true;
    } catch (Exception e) {
      log.error(e.getMessage());
      return false;
    } finally {
      itimContext.logout();
    }
  }
コード例 #2
0
ファイル: ItimImpl.java プロジェクト: self-java/self-java
  public Person getPerson(String uid) {
    Person owner = null;

    try {
      itimContext.login();

      String containerFilter = "(&((objectclass=erPersonItem))(uid=" + uid + "))";

      SearchMO searchMO = new SearchMO(itimContext.getPlatform(), itimContext.getSubject());
      searchMO.setCategory(ObjectProfileCategory.PERSON);
      String TENANT_DN = "ou=unicom,dc=unicom";
      searchMO.setContext(new CompoundDN(new DistinguishedName(TENANT_DN)));
      searchMO.setProfileName("Person");
      searchMO.setFilter(containerFilter);
      Collection people = searchMO.execute().getResults();
      if (people.size() > 0) {
        owner = (Person) people.iterator().next();
      } else {
        log.info("TIM中查无此人!员工编码为:" + uid);
      }
      return owner;
    } catch (Exception e) {
      log.error("search person:" + e.getMessage());
      return owner;
    } finally {
      itimContext.logout();
    }
  }