File: sasl_external.c

package info (click to toggle)
ldap-haskell 0.6.11-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 164 kB
  • sloc: haskell: 83; ansic: 34; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 1,051 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <ldap.h>
#include <sasl/sasl.h>

#include "sasl_external.h"

struct external_defaults {
  const char *authzPtr;
  int authzLen;
};

static int external_interact (LDAP *ld, unsigned flags, void *defaults, void *sasl_interact)
{
  (void)ld;
  (void)flags;
  struct external_defaults *defs = defaults;
  sasl_interact_t *interact;

  for (interact = sasl_interact; interact->id != SASL_CB_LIST_END; interact++) {
    switch (interact->id) {
    case SASL_CB_USER:
      if (defs->authzLen) {
        interact->result = defs->authzPtr;
        interact->len = defs->authzLen;
      }
      break;
    /* RFC 4422 (SASL) doesn't allow any other callbacks for EXTERNAL */
    }
  }
  return LDAP_SUCCESS;
}

int external_sasl_bind (LDAP *ld, const char *authz, int len)
{
  struct external_defaults defaults = { authzPtr: authz, authzLen: len };

  return ldap_sasl_interactive_bind_s (ld, NULL, "EXTERNAL", NULL, NULL,
                                       LDAP_SASL_QUIET,
                                       external_interact, &defaults);
}