活动目录:移动用户不同的OU移动用户、不同、目录、OU

由网友(温情先生温情范)分享简介:我是开发一个应用程序,需要创建和维护用户到Active Directory。我的问题是,用户有一个层次结构和主可以使用不同的密码过期值创建。我在读有关,也许有可能使用的OU做到这一点,但我无法找到关于它的一些code例子。 也许存在一个更好的办法的要求,但不幸的是这是我发现的唯一途径。解决方案(对我的工作) 当您正在创...

我是开发一个应用程序,需要创建和维护用户到Active Directory。

我的问题是,用户有一个层次结构和主可以使用不同的密码过期值创建。我在读有关,也许有可能使用的OU做到这一点,但我无法找到关于它的一些code例子。

也许存在一个更好的办法的要求,但不幸的是这是我发现的唯一途径。

解决方案(对我的工作)

当您正在创建的专有名称(DN),你必须添加的OU入值。这是code,我做:

 保护字符串getDN(用户用户)
{
  //用户名
  串的dn =CN =+ user.getLogin();

  // OU
  字符串OU;
  如果(user.getPasswordExpirationTime()== 1)
    OU =PJ1; //一天
  否则,如果(usuario.getPasswordExpirationTime()== 30)
    OU =PJ30; //30天
  否则如果(usuario.getPasswordExpirationTime()== 60)
    OU =PJ60; //60天
  其他
    OU =PJ90; //默认情况下,90天

  DN + =,OU =+欧;

  //域
  DN + =,DC =域,DC =本地;

  返回DN;
}
 

解决方案 系统目录转移工具 下载,系统目录转移工具 v1.0 嗨客软件下载站

下面是如何做到这一点一个例子:

 字符串oldUserName =CN =爱因斯坦,OU =研究,DC =拓地,DC = COM;
字符串newUserName =CN =爱因斯坦,OU =销售额,DC =拓地,DC = COM;
//创建初始目录上下文
LdapContext的CTX =新InitialLdapContext(ENV,NULL);
//移动用户
ctx.rename(oldUserName,newUserName);
 

https://forums.oracle.com/forums/thread.jspa?主题ID = 1157099

I'm develop an app that needs create and maintain users into the active directory.

My problem is that the users have a hierarchy and the master can create them with different password expiration values. I was reading about that and maybe it's possible do it using OUs , but I can't found some code example about it.

Maybe exist a better way to do the requirement, but unfortunately this is the only way that I found.

Solution (that work for me)

When you are creating the distinguished name (dn), you have to add the the OU into the value. This is the code that I made:

protected String getDN(User user)
{
  //User name
  String dn = "CN=" + user.getLogin();

  //OU
  String ou;
  if (user.getPasswordExpirationTime() == 1)
    ou = "PJ1"; //one day
  else if (usuario.getPasswordExpirationTime() == 30)
    ou = "PJ30"; //thirty days
  else if (usuario.getPasswordExpirationTime() == 60)
    ou = "PJ60"; //sixty days
  else
    ou = "PJ90"; //default, ninety days

  dn += ",OU=" + ou;

  //Domain
  dn += ",DC=domain,DC=local";

  return dn;
}

解决方案

Here is a example on how to do it:

String oldUserName = "CN=Albert Einstein,OU=Research,DC=antipodes,DC=com";
String newUserName = "CN=Albert Einstein,OU=Sales,DC=antipodes,DC=com";
// Create the initial directory context
LdapContext ctx = new InitialLdapContext(env,null);
// Move the user
ctx.rename(oldUserName,newUserName);

https://forums.oracle.com/forums/thread.jspa?threadID=1157099

阅读全文

相关推荐

最新文章