>From 785e4bc2298677c8a322b00b7d42a7c7e67fe4c5 Mon Sep 17 00:00:00 2001 From: Fraser Tweedale Date: Mon, 13 Apr 2015 01:19:58 -0400 Subject: [PATCH 32/33] Get profile ID from DN instead of CN attribute --- .../cmscore/profile/LDAPProfileSubsystem.java | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java b/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java index c7963498dfffe90ec6b9cd83d351385a8686f913..cdb5a36a95e9cf25429b80b27686416d28a05632 100644 --- a/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java +++ b/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java @@ -35,6 +35,7 @@ import netscape.ldap.LDAPSearchResults; import netscape.ldap.controls.LDAPEntryChangeControl; import netscape.ldap.controls.LDAPPersistSearchControl; import netscape.ldap.util.DN; +import netscape.security.x509.X500Name; import com.netscape.certsrv.apps.CMS; import com.netscape.certsrv.base.EBaseException; @@ -106,8 +107,14 @@ public class LDAPProfileSubsystem IPluginRegistry registry = (IPluginRegistry) CMS.getSubsystem(CMS.SUBSYSTEM_REGISTRY); - String profileId = (String) - ldapProfile.getAttribute("cn").getStringValues().nextElement(); + String profileId = null; + String dn = ldapProfile.getDN(); + try { + profileId = new X500Name(dn).getCommonName(); + } catch (IOException e) { + CMS.debug("Error reading profile entry: DN " + dn + "has no common name"); + return; + } String classId = (String) ldapProfile.getAttribute("classId").getStringValues().nextElement(); @@ -218,13 +225,15 @@ public class LDAPProfileSubsystem } private void forgetProfile(LDAPEntry entry) { - String profileId = (String) - entry.getAttribute("cn").getStringValues().nextElement(); - if (profileId == null) { + String profileId = null; + String dn = entry.getDN(); + try { + profileId = new X500Name(dn).getCommonName(); + } catch (IOException e) { CMS.debug("forgetProfile: error retrieving cn (profileId) from LDAPEntry"); - } else { - forgetProfile(profileId); + return; } + forgetProfile(profileId); } /** -- 2.1.0