Forum Discussion
APM LDAP by path
Shoot. Sorry I misunderstood the internal writeup on this. Instead of not escaping itself it looks like it expects *you* to escape it manually. Can you try setting it to "\66\69\65\6C\64\3D\2A"? That should be "field=*".
You're going to have to double-escape them inside the iRule or policy agent config. TCL gets weird with escaping sometimes. The example I've got from bigip.conf where the variable is being set from a var-assign policy agent to "medusademo" to formulate a search filter is:
apm policy agent variable-assign /Common/ldaptest_act_variable_assign_ag {
variables {
{
expression "expr { \"\\\\59\\\\87\\\\FB\\\\A6\\\\AB\\\\1E\\\\D7\\\\40\\\\BE\\\\F8\\\\C7\\\\66\\\\C7\\\\DE\\\\CD\\\\56\" }"
varname session.objectguid.foo
}
}
}
apm policy agent aaa-ldap /Common/ldap_query_bar_act_ldap_query_ag {
filter "objectGUID=%{session.objectguid.foo}"
search-dn cn=users,dc=lab,dc=apm,dc=f5test,dc=local
server /Common/ldapQATest4
type query
}
If it doesn't work at first, packet capture a plaintext LDAP query so you can see what it's sending on the wire, the escaping might not be exactly right.
I added this in my iRule.
ACCESS::session data set session.ldapsearch "\\66\\69\\65\\6C\\64\\3D\\2A"
catch {log local0. "sls=[ACCESS::session data get session.ldapsearch]"}Output:
2022-12-14T11:20:24.600-07:00 <f5> info tmm1[12587]: Rule /Common/<vip> <ACCESS_POLICY_AGENT_EVENT>: sls=\66\69\65\6C\64\3D\2Ahowever, I get this:
2022-12-14T11:20:25.517-07:00 <f5> err apmd[5091]: 01490235:3: /Common/<access policy>:Common:6c31ab75: LDAP Module: Failed to make ldap_search in '<search dn>' with filter '(&(<user filter>)(\5c66\5c69\5c65\5c6C\5c64\5c3D\5c2A))' and scope '2'. Bad search filter.The entries in <> are redacted. The "\5c66\5c69\5c65\5c6C\5c64\5c3D\5c2A" here is the search, which, as you can see, is still expanded from "\66\69\65\6C\64\3D\2A". So escaping it in the iRule and session variable, means it gets double-escaped in the ldap search.
I rebooted the F5 and failed it back to primary before running this test. The db entry is still set:
# tmsh list sys db apm.ldap.autoescape one-line
sys db apm.ldap.autoescape { value "disable" }redacted details:
# tmsh list apm policy agent aaa-ldap /Common/<policy>_act_ldap_query_ag
apm policy agent aaa-ldap <policy>_act_ldap_query_ag {
filter "(&(<id>=%{session.oauth.client.last.id_token.<idname>})(%{session.ldapsearch}))"
search-dn <searchdn>
server <ldap>
show-extended-error true
type query
}Thoughts?
- TimRikerDec 14, 2022
Cirrocumulus
Putting the entire search in via the irule and setting SearchFilter to %{session.ldapsearch} also gets escaped. Using this set:
ACCESS::session data set session.ldapsearch "(&(<id>=[ACCESS::session data get session.oauth.client.last.id_token.<id name>])(field=*))" catch {log local0. "sls=[ACCESS::session data get session.ldapsearch]"}Logs correctly:
2022-12-14T11:38:57.390-07:00 <f5> info tmm[12587]: Rule /Common/<rule> <ACCESS_POLICY_AGENT_EVENT>: sls=(&(<id>=<user id>)(field=*))Redacted output:
2022-12-14T11:38:57.400-07:00 <f5> err apmd[5091]: 01490235:3: /Common/<policy>:Common:1bda35bc: LDAP Module: Failed to make ldap_search in '<searchdn>' with filter '\28&\28<id>=<user id>\29\28field=\2a\29\29' and scope '2'. Bad search filter.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com