001package com.hfg.ldap; 002 003 004import com.hfg.ldap.ad.ActiveDirectoryField; 005import com.hfg.util.CompareUtil; 006import com.hfg.util.StringUtil; 007import com.hfg.util.UserImpl; 008 009//------------------------------------------------------------------------------ 010/** 011 Container for LDAP user information. 012 <div> 013 @author J. Alex Taylor, hairyfatguy.com 014 </div> 015 */ 016//------------------------------------------------------------------------------ 017// com.hfg XML/HTML Coding Library 018// 019// This library is free software; you can redistribute it and/or 020// modify it under the terms of the GNU Lesser General Public 021// License as published by the Free Software Foundation; either 022// version 2.1 of the License, or (at your option) any later version. 023// 024// This library is distributed in the hope that it will be useful, 025// but WITHOUT ANY WARRANTY; without even the implied warranty of 026// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 027// Lesser General Public License for more details. 028// 029// You should have received a copy of the GNU Lesser General Public 030// License along with this library; if not, write to the Free Software 031// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 032// 033// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 034// jataylor@hairyfatguy.com 035//------------------------------------------------------------------------------ 036 037public class LDAP_User extends UserImpl 038{ 039 040 //-------------------------------------------------------------------------- 041 @Override 042 public LDAP_User setField(String inName, String inValue) 043 { 044 super.setField(inName, inValue); 045 046 // If it matches one of these standard fields, set the value there as well 047 if (inName.equalsIgnoreCase(LDAP_Field.UID) 048 || inName.equals(ActiveDirectoryField.SAM_ACCOUNT_NAME)) // Active Directory's default uid field 049 { 050 setUID(inValue); 051 } 052 else if (inName.equalsIgnoreCase(LDAP_Field.SN)) 053 { 054 setSurname(inValue); 055 } 056 else if (inName.equalsIgnoreCase(LDAP_Field.CN)) 057 { 058 setName(inValue); 059 } 060 else if (inName.equalsIgnoreCase(LDAP_Field.LOCATION)) 061 { 062 setLocation(inValue); 063 } 064 else if (inName.equalsIgnoreCase(LDAP_Field.GIVEN_NAME) 065 || inName.equalsIgnoreCase(LDAP_Field.FIRST_NAME)) 066 { 067 setFirstName(inValue); 068 } 069 else if (inName.equalsIgnoreCase(LDAP_Field.PREFERRED_NAME)) 070 { 071 setPreferredName(inValue); 072 } 073 else if (inName.equalsIgnoreCase(LDAP_Field.EMAIL)) 074 { 075 setEmail(inValue); 076 } 077 else if (inName.equalsIgnoreCase(ActiveDirectoryField.USER_PRINCIPAL_NAME) // Active Directory's default email field 078 && inValue.contains("@") 079 && !StringUtil.isSet(getEmail())) 080 { 081 setEmail(inValue); 082 } 083 084 085 return this; 086 } 087 088 //-------------------------------------------------------------------------- 089 @Override 090 public boolean equals(Object inObj2) 091 { 092 if (!(inObj2 instanceof LDAP_User)) 093 { 094 return false; 095 } 096 097 return 0 == CompareUtil.compare(getUID(), ((LDAP_User) inObj2).getUID()); 098 } 099 100}