New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LDAP API improvements #246

Closed
jeffdiclemente opened this Issue Oct 23, 2017 · 0 comments

Comments

Projects
1 participant
@jeffdiclemente
Contributor

jeffdiclemente commented Oct 23, 2017

Use Case

I want to construct long LDAP expressions and conditionally modify them using concise modern C++.

Pain Point

LDAP expressions can be conditionally built however it requires more code than is necessary...

LDAPFilter filter(LDAPProp("key1") == "value1");

if (someCondition) {
    filter = LDAPFilter(LDAPPropExpr(filter.ToString()) || LDAPProp("key2") == "value2");
} else {
    filter = LDAPFilter(LDAPPropExpr(filter.ToString()) || LDAPProp("key3") == "value3");
}

This is not only more code to write for clients, its also wasteful since extra temporary objects need to be created.

Solution

  • Make LDAPPropExpr::operator= and LDAPProp::operator= public.
  • Implement LDAPProp::operator|= andLDAPProp::operator&=

This allows the following to be written...

LDAPPropExpr expr(LDAPProp("key1") == "value1");

if (someCondition) {
    expr = expr || LDAPProp("key2") == "value2"; // or even more conveniently, expr |= LDAPProp("key2") == "value2";
} else {
    expr = expr || LDAPProp("key3") == "value3";
}

And even more concisely...

LDAPPropExpr expr(LDAPProp("key1") == "value1");

if (someCondition) {
    expr |= LDAPProp("key2") == "value2";
} else {
    expr |= LDAPProp("key3") == "value3";
}

@jeffdiclemente jeffdiclemente self-assigned this Oct 23, 2017

jeffdiclemente added a commit that referenced this issue Oct 26, 2017

Support constructing long LDAP expressions using concise C++
Fixes #246

Signed-off-by: The Mathworks Inc <Roy.Lurie@mathworks.com>

@jeffdiclemente jeffdiclemente added this to In Progress in Release 3.3 Oct 30, 2017

jeffdiclemente added a commit that referenced this issue Oct 30, 2017

Support constructing long LDAP expressions using concise C++ (#247)
Fixes #246

Signed-off-by: The Mathworks Inc <Roy.Lurie@mathworks.com>

@jeffdiclemente jeffdiclemente moved this from In Progress to Done in Release 3.3 Nov 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment