>From b4280b4d02ffca89ed154188c025d26abc0386be Mon Sep 17 00:00:00 2001 From: Fraser Tweedale Date: Mon, 13 Apr 2015 01:19:58 -0400 Subject: [PATCH] Get profile ID from DN instead of CN attribute --- .../cmscore/profile/LDAPProfileSubsystem.java | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 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 0c390be581f12d8364c2ea95c62dd4ab8da93cbb..bd41f94885587076b5ba871cf84efd4199e7359d 100644 --- a/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java +++ b/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java @@ -28,6 +28,7 @@ import java.util.Vector; import netscape.ldap.LDAPAttribute; import netscape.ldap.LDAPConnection; import netscape.ldap.LDAPControl; +import netscape.ldap.LDAPDN; import netscape.ldap.LDAPEntry; import netscape.ldap.LDAPException; import netscape.ldap.LDAPSearchConstraints; @@ -106,8 +107,13 @@ 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(); + if (!dn.startsWith("cn=")) { + CMS.debug("Error reading profile entry: DN " + dn + " does not start with 'cn='"); + return; + } + profileId = LDAPDN.explodeDN(dn, true)[0]; String classId = (String) ldapProfile.getAttribute("classId").getStringValues().nextElement(); @@ -218,13 +224,14 @@ public class LDAPProfileSubsystem } private void forgetProfile(LDAPEntry entry) { - String profileId = (String) - entry.getAttribute("cn").getStringValues().nextElement(); - if (profileId == null) { - CMS.debug("forgetProfile: error retrieving cn (profileId) from LDAPEntry"); - } else { - forgetProfile(profileId); + String profileId = null; + String dn = entry.getDN(); + if (!dn.startsWith("cn=")) { + CMS.debug("forgetProfile: DN " + dn + " does not start with 'cn='"); + return; } + profileId = LDAPDN.explodeDN(dn, true)[0]; + forgetProfile(profileId); } /** -- 2.1.0