summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/ldap.h
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2015-02-24 20:52:57 +0000
committerCorinna Vinschen <corinna@vinschen.de>2015-02-24 20:52:57 +0000
commitad8d295e7c02a289d11b7ab3e7c7e36af934adde (patch)
tree3893feff97d034c24f0714f5753fcf599dc445bf /winsup/cygwin/ldap.h
parent59076540bce2380bade31edba78b8dd421a03d3c (diff)
downloadcygnal-ad8d295e7c02a289d11b7ab3e7c7e36af934adde.tar.gz
cygnal-ad8d295e7c02a289d11b7ab3e7c7e36af934adde.tar.bz2
cygnal-ad8d295e7c02a289d11b7ab3e7c7e36af934adde.zip
* ldap.h: Remove index macros.
(class cyg_ldap): Remove members srch_msg and srch_entry. (cyg_ldap::get_string_attribute): Remove private method taking index argument. (cyg_ldap::get_num_attribute): Ditto. Add method taking attribute name. (cyg_ldap::get_primary_gid): Adjust to aforementioned change. (cyg_ldap::get_unix_uid): Ditto. (cyg_ldap::get_unix_gid): Ditto. * ldap.cc: Throughout, use msg and entry in place of srch_msg and srch_entry. (std_user_attr): Add sAMAccountName and objectSid. (group_attr): Ditto. (cyg_ldap::close): Drop handling of srch_msg and srch_entry. (cyg_ldap::get_string_attribute): Move earlier in file. (cyg_ldap::get_num_attribute): Ditto. (cyg_ldap::enumerate_ad_accounts): Add comments for clarity. Use group_attr or user_attr rather than sid_attr to fetch all desired attributes for an account right away. (cyg_ldap::next_account): Store found SID in last_fetched_sid to skip calls to fetch_ad_account from fetch_account_from_windows. (cyg_ldap::get_string_attribute): Remove method taking index argument. (cyg_ldap::get_num_attribute): Ditto. * pwdgrp.h (class pg_ent): Fix formatting. Add member dom. * passwd.cc (pg_ent::enumerate_ad): Store current flat domain name in dom. Construct fetch_acc_t argument from LDAP attributes and call fetch_account_from_windows with that. * userinfo.h (enum fetch_user_arg_type_t): Rename FULL_grp_arg to FULL_acc_arg. Change throughout. (struct fetch_acc_t): Rename from fetch_full_grp_t. Change throughout. (struct fetch_user_arg_t): Rename full_grp to full_acc. Change throughout.
Diffstat (limited to 'winsup/cygwin/ldap.h')
-rw-r--r--winsup/cygwin/ldap.h24
1 files changed, 8 insertions, 16 deletions
diff --git a/winsup/cygwin/ldap.h b/winsup/cygwin/ldap.h
index 9209d854b..4b696df22 100644
--- a/winsup/cygwin/ldap.h
+++ b/winsup/cygwin/ldap.h
@@ -17,12 +17,6 @@ details. */
#include <ntldap.h>
#pragma pop_macro ("DECLSPEC_IMPORT")
-#define LDAP_USER_PGRP_ATTR 0
-#define LDAP_USER_UID_ATTR 1
-
-#define LDAP_GROUP_NAME_ATTR 0
-#define LDAP_GROUP_GID_ATTR 1
-
class cyg_ldap {
PLDAP lh;
PWCHAR def_context;
@@ -31,7 +25,6 @@ class cyg_ldap {
PWCHAR *attr;
bool isAD;
PLDAPSearch srch_id;
- PLDAPMessage srch_msg, srch_entry;
cygsid last_fetched_sid;
inline int map_ldaperr_to_errno (ULONG lerr);
@@ -41,13 +34,11 @@ class cyg_ldap {
inline int next_page ();
bool fetch_unix_sid_from_ad (uint32_t id, cygsid &sid, bool group);
PWCHAR fetch_unix_name_from_rfc2307 (uint32_t id, bool group);
- PWCHAR get_string_attribute (int idx);
- uint32_t get_num_attribute (int idx);
public:
cyg_ldap () : lh (NULL), def_context (NULL), msg (NULL), entry (NULL),
- val (NULL), isAD (false), srch_id (NULL), srch_msg (NULL),
- srch_entry (NULL), last_fetched_sid (NO_SID)
+ val (NULL), isAD (false), srch_id (NULL),
+ last_fetched_sid (NO_SID)
{}
~cyg_ldap () { close (); }
@@ -60,6 +51,8 @@ public:
operator PLDAP () const { return lh; }
int open (PCWSTR in_domain);
void close ();
+ PWCHAR get_string_attribute (PCWSTR name);
+ uint32_t get_num_attribute (PCWSTR name);
bool fetch_ad_account (PSID sid, bool group, PCWSTR domain = NULL);
int enumerate_ad_accounts (PCWSTR domain, bool group);
int next_account (cygsid &sid);
@@ -67,11 +60,10 @@ public:
uid_t remap_uid (uid_t uid);
gid_t remap_gid (gid_t gid);
/* User only */
- gid_t get_primary_gid () { return get_num_attribute (LDAP_USER_PGRP_ATTR); }
- gid_t get_unix_uid () { return get_num_attribute (LDAP_USER_UID_ATTR); }
+ gid_t get_primary_gid () { return get_num_attribute (L"primaryGroupID"); }
+ gid_t get_unix_uid () { return get_num_attribute (L"uidNumber"); }
/* group only */
PWCHAR get_group_name ()
- { return get_string_attribute (LDAP_GROUP_NAME_ATTR); }
- gid_t get_unix_gid () { return get_num_attribute (LDAP_GROUP_GID_ATTR); }
- PWCHAR get_string_attribute (PCWSTR name);
+ { return get_string_attribute (L"sAMAccountName"); }
+ gid_t get_unix_gid () { return get_num_attribute (L"gidNumber"); }
};