From 398aa8aca0505ce3d310c621661907693fd76e6d Mon Sep 17 00:00:00 2001 From: Fraser Tweedale Date: Mon, 13 Apr 2015 01:19:58 -0400 Subject: Get profile ID from DN instead of CN attribute --- .../cmscore/profile/LDAPProfileSubsystem.java | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'base/server/cmscore/src/com/netscape/cmscore') 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 a7974430f..199a5576e 100644 --- a/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java +++ b/base/server/cmscore/src/com/netscape/cmscore/profile/LDAPProfileSubsystem.java @@ -29,6 +29,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; @@ -107,8 +108,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(); @@ -219,13 +225,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); } /** -- cgit