net.sourceforge.heracles.dao.impl
Class LdapQueryImpl

java.lang.Object
  extended by net.sourceforge.heracles.dao.impl.LdapQueryImpl
All Implemented Interfaces:
LdapQuery

public class LdapQueryImpl
extends java.lang.Object
implements LdapQuery

Title: KerberosQueryImpl.java
Description: This class communicats with JNDI
Java Version: JDK 1.5

Author:
Philipp Gantert version 1.0

Field Summary
private  javax.naming.directory.DirContext ctx
           
private  java.lang.String emptyValues
           
private  java.util.Hashtable<java.lang.String,java.lang.String> envoierment
           
private  HeraclesConfig heraclesConfig
           
private  org.apache.log4j.Logger logger
           
private  java.lang.String searchBase
           
 
Constructor Summary
LdapQueryImpl()
           
 
Method Summary
private  java.util.Date convertDate(long lastLogon)
          A Win32 OS has an other time epoch.
private  LdapUser createLdapUser(javax.naming.directory.SearchResult searchResult)
          The result of our search has all the values, which we must convert in a LdapUser object.
private  void defineEnvoierment(java.lang.String domainName)
           
private  LdapUser defineUserAccountControl(LdapUser ldapUser, int userAccountControl)
          This is a help method to define if the user account diabled and is the password expired.
private  javax.naming.NamingEnumeration<javax.naming.directory.SearchResult> queryLdap(java.lang.String where, java.lang.String like)
          This helper method search in the ldap service.
 java.util.List<LdapUser> searchInLdap(java.lang.String domainName, java.lang.String where, java.lang.String like)
           
 void setHeraclesConfig(HeraclesConfig heraclesConfig)
           
private  java.util.List<LdapGroup> takeRole(javax.naming.NamingEnumeration roles)
          This helper method creates LdapGroup objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

heraclesConfig

private HeraclesConfig heraclesConfig

envoierment

private java.util.Hashtable<java.lang.String,java.lang.String> envoierment

ctx

private javax.naming.directory.DirContext ctx

logger

private org.apache.log4j.Logger logger

emptyValues

private java.lang.String emptyValues

searchBase

private java.lang.String searchBase
Constructor Detail

LdapQueryImpl

public LdapQueryImpl()
Method Detail

setHeraclesConfig

public void setHeraclesConfig(HeraclesConfig heraclesConfig)
Parameters:
heraclesConfig - the heraclesConfig to set

defineEnvoierment

private void defineEnvoierment(java.lang.String domainName)
                        throws HeraclesException
Throws:
HeraclesException

searchInLdap

public java.util.List<LdapUser> searchInLdap(java.lang.String domainName,
                                             java.lang.String where,
                                             java.lang.String like)
                                      throws javax.naming.NamingException,
                                             HeraclesException
Specified by:
searchInLdap in interface LdapQuery
Parameters:
domainName -
where -
like -
Returns:
List
Throws:
javax.naming.NamingException
HeraclesException

queryLdap

private javax.naming.NamingEnumeration<javax.naming.directory.SearchResult> queryLdap(java.lang.String where,
                                                                                      java.lang.String like)
                                                                               throws javax.naming.NamingException
This helper method search in the ldap service. We define all the attributes, which are interressting for us and we define a search filter.
The results will be in a NamingEnumaration object.

Parameters:
where -
like -
Returns:
NamingException
Throws:
javax.naming.NamingException

createLdapUser

private LdapUser createLdapUser(javax.naming.directory.SearchResult searchResult)
The result of our search has all the values, which we must convert in a LdapUser object.

Parameters:
searchResult -
Returns:
LdapUser

takeRole

private java.util.List<LdapGroup> takeRole(javax.naming.NamingEnumeration roles)
This helper method creates LdapGroup objects. Then the memberOf attribute of the ldap user object, includes every group which the user is a member of.
So we must create of every group create a new LdapGroup object. These objects will be saved in a list and this list will store in a ldapUser object.

Parameters:
roles -
Returns:
List

defineUserAccountControl

private LdapUser defineUserAccountControl(LdapUser ldapUser,
                                          int userAccountControl)
This is a help method to define if the user account diabled and is the password expired. The problem is, that these informations are store in the sam integer value, as many other informations. For more informations about this, please have a look at:
http://support.microsoft.com/kb/305144/en-us

Parameters:
ldapUser -
userAccountControl -
Returns:
LdapUser

convertDate

private java.util.Date convertDate(long lastLogon)
A Win32 OS has an other time epoch. Win32 starts at 1.1.1601 and the standard of java is 1.1.1970. For more informations: http://forum.java.sun.com/thread.jspa?threadID=716240&messageID=4267441

Parameters:
lastLogon -
Returns:
Date


Copyright © 2007 null. All Rights Reserved.