Print this page
NEX-17849 idmap fails to lookup group SID in AD
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/idmap/idmapd/adutils.c
          +++ new/usr/src/cmd/idmap/idmapd/adutils.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
       24 + *
       25 + * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
  24   26   */
  25   27  
  26   28  /*
  27   29   * Processes name2sid & sid2name batched lookups for a given user or
  28   30   * computer from an AD Directory server using GSSAPI authentication
  29   31   */
  30   32  
  31   33  #include <stdio.h>
  32   34  #include <stdlib.h>
  33   35  #include <alloca.h>
↓ open down ↓ 18 lines elided ↑ open up ↑
  52   54  
  53   55  /* Attribute names and filter format strings */
  54   56  #define SAN             "sAMAccountName"
  55   57  #define OBJSID          "objectSid"
  56   58  #define OBJCLASS        "objectClass"
  57   59  #define UIDNUMBER       "uidNumber"
  58   60  #define GIDNUMBER       "gidNumber"
  59   61  #define UIDNUMBERFILTER "(&(objectclass=user)(uidNumber=%u))"
  60   62  #define GIDNUMBERFILTER "(&(objectclass=group)(gidNumber=%u))"
  61   63  #define SANFILTER       "(sAMAccountName=%s)"
  62      -#define OBJSIDFILTER    "(objectSid=%s)"
       64 +#define OBJSIDFILTER    "(|(objectSid=%s)(sIDHistory=%s))"
  63   65  
  64   66  void    idmap_ldap_res_search_cb(LDAP *ld, LDAPMessage **res, int rc,
  65   67                  int qid, void *argp);
  66   68  
  67   69  /*
  68   70   * A place to put the results of a batched (async) query
  69   71   *
  70   72   * There is one of these for every query added to a batch object
  71   73   * (idmap_query_state, see below).
  72   74   */
↓ open down ↓ 712 lines elided ↑ open up ↑
 785  787           */
 786  788  
 787  789          if (!adutils_lookup_check_sid_prefix(state->qs, sid))
 788  790                  return (IDMAP_ERR_DOMAIN_NOTFOUND);
 789  791  
 790  792          ret = adutils_txtsid2hexbinsid(sid, rid, &cbinsid[0], sizeof (cbinsid));
 791  793          if (ret != 0)
 792  794                  return (IDMAP_ERR_SID);
 793  795  
 794  796          /* Assemble filter */
 795      -        (void) asprintf(&filter, OBJSIDFILTER, cbinsid);
      797 +        (void) asprintf(&filter, OBJSIDFILTER, cbinsid, cbinsid);
 796  798          if (filter == NULL)
 797  799                  return (IDMAP_ERR_MEMORY);
 798  800  
 799  801          retcode = idmap_batch_add1(state, filter, NULL, NULL, esidtype,
 800  802              dn, attr, value, name, dname, NULL, NULL, sid_type, unixname,
 801  803              pid, rc);
 802  804  
 803  805          free(filter);
 804  806  
 805  807          return (retcode);
↓ open down ↓ 92 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX