Hi,

I am using Access Manager v4.2.
I want to get LDAP attributes using Policy Extension.
For this, I created one Policy Extension
Type: Condition
Policy Type: Identity Server: Roles

In configuration parameter, I configure debug, LDAP User DN and LDAP
Attribute:givenName
So I am able to get values of debug and LDAP User DN on Extension API
but for givenName I am getting null value.

My code is given below

Code:
--------------------
public class PolicyConditionExtnTemplate implements NxpeCondition {
private String interfaceID;
private boolean debug;
private NxpeParameterList configurationValues;
private static final String DEBUG_NAME = "Debug";
private static final int EV_DEBUG = 91;

private static final String LDAP_USER_DN_NAME = "LDAP User DN";
private static final int EV_LDAP_USER_DN = 41;

private static final String LDAP_USER_First_Name = "LDAP User First Name";
private static final int EV_LDAP_USER_First_Name = 12;

@Override
public void initialize(NxpeParameterList configurationValues) throws NxpeException {
this.configurationValues = configurationValues;
this.debug = true;
setDebug(configurationValues);
}

@Override
public void setInterfaceId(String arg0) throws NxpeException {
this.interfaceID = arg0;
}

@Override
public NxpeResult evaluate(NxpeInformationContext informationContext, NxpeResponseContext responseContext)
throws NxpeException {
String strLDAPUserDN = "";
String strLDAPFN = "";
NxpeResult res = NxpeResult.ConditionFalse;

try {
strLDAPUserDN = getLDAPUserDN(informationContext);
if (strLDAPUserDN != null && !strLDAPUserDN.isEmpty()) {
if (debug) {
System.out.println("PolicyConditionExtnTemplate strLDAPUserDN : " + strLDAPUserDN);
}
}

strLDAPFN = getLDAPUserFirstName(informationContext);
if (strLDAPFN != null && !strLDAPFN.isEmpty()) {
if (debug) {
System.out.println("PolicyConditionExtnTemplate strLDAPFN : " + strLDAPFN);
}
}

res = NxpeResult.ConditionTrue;
} catch (NxpeException ex) {
if (debug) {
ex.printStackTrace();
}
res = NxpeResult.ConditionFalse;
}

if (debug)
System.out.println(" PolicyConditionExtnTemplate : Exiting...");
return res;
}

private void setDebug(NxpeParameterList configurationValues) throws NxpeException {
NxpeParameter parameter = configurationValues.getParameter(EV_DEBUG);
if (parameter != null) {
this.debug = Boolean.parseBoolean(parameter.getValue());
}
}

private String getLDAPUserDN(NxpeInformationContext informationContext) throws NxpeException {
NxpeParameter pLDAPUserDN;

if ((pLDAPUserDN = this.configurationValues.getParameter(EV_LDAP_USER _DN)) != null) {
String strLDAPUserDN = (String) informationContext.getData(pLDAPUserDN);
return strLDAPUserDN;
} else {
NxpeException nxpeException = new NxpeException(NxpeResult.ErrorDataUnavailable,
"PolicyConditionExtnTemplate :" + LDAP_USER_DN_NAME + ": not present.");
throw (nxpeException);
}
}

private String getLDAPUserFirstName(NxpeInformationContext informationContext) throws NxpeException {
NxpeParameter pLDAPUserFirstName;

if ((pLDAPUserFirstName = this.configurationValues.getParameter(EV_LDAP_USER _First_Name)) != null) {
String strLDAPUserFN = (String) informationContext.getData(pLDAPUserFirstName);
return strLDAPUserFN;
} else {
NxpeException nxpeException = new NxpeException(NxpeResult.ErrorDataUnavailable,
"PolicyConditionExtnTemplate :" + LDAP_USER_First_Name + ": not present.");
throw (nxpeException);
}
}
}
--------------------


When I see the IDP log I am getting the below Message

Code:
--------------------
PolicyConditionExtnTemplate :LDAP User First Name: not present.
--------------------


--
fartyalvikram
------------------------------------------------------------------------
fartyalvikram's Profile: https://forums.netiq.com/member.php?userid=13055
View this thread: https://forums.netiq.com/showthread.php?t=57271