summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/passwd.cc
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/passwd.cc
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/passwd.cc')
-rw-r--r--winsup/cygwin/passwd.cc20
1 files changed, 17 insertions, 3 deletions
diff --git a/winsup/cygwin/passwd.cc b/winsup/cygwin/passwd.cc
index b8ed09466..825b2e0a8 100644
--- a/winsup/cygwin/passwd.cc
+++ b/winsup/cygwin/passwd.cc
@@ -1,7 +1,7 @@
/* passwd.cc: getpwnam () and friends
Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008,
- 2009, 2010, 2011, 2012, 2013, 2014 Red Hat, Inc.
+ 2009, 2010, 2011, 2012, 2013, 2014, 2015 Red Hat, Inc.
This file is part of Cygwin.
@@ -600,6 +600,7 @@ pg_ent::enumerate_ad ()
if (!nss_db_enum_primary ()
|| cldap.enumerate_ad_accounts (NULL, group) != NO_ERROR)
continue;
+ RtlInitUnicodeString (&dom, cygheap->dom.primary_flat_name ());
}
else if ((td = cygheap->dom.trusted_domain (resume - 1)))
{
@@ -616,6 +617,7 @@ pg_ent::enumerate_ad ()
|| cldap.enumerate_ad_accounts (td->DnsDomainName, group)
!= NO_ERROR)
continue;
+ RtlInitUnicodeString (&dom, td->NetbiosDomainName);
}
else
{
@@ -628,9 +630,21 @@ pg_ent::enumerate_ad ()
int ret = cldap.next_account (sid);
if (ret == NO_ERROR)
{
+ fetch_acc_t full;
fetch_user_arg_t arg;
- arg.type = SID_arg;
- arg.sid = &sid;
+ UNICODE_STRING name;
+
+ arg.type = FULL_acc_arg;
+ arg.full_acc = &full;
+ full.sid = sid;
+ RtlInitUnicodeString (&name,
+ cldap.get_string_attribute (L"sAMAccountName"));
+ full.name = &name;
+ full.dom = &dom;
+ if (sid_sub_auth (sid, 0) == SECURITY_BUILTIN_DOMAIN_RID)
+ full.acc_type = SidTypeAlias;
+ else
+ full.acc_type = group ? SidTypeGroup : SidTypeUser;
char *line = pg.fetch_account_from_windows (arg, &cldap);
if (line)
return pg.add_account_post_fetch (line, false);