mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-15 19:09:58 +08:00
93d15b36ef
(install-ldif): New target to install cygwin.ldif. * cygheap.h (class cygheap_pwdgrp): Rename pfx_t to nss_pfx_t. Add PFX to enum value. Add nss_scheme_method enum and nss_scheme_t structure. Add home_scheme, shell_scheme and gecos_scheme members. (NSS_SCHEME_MAX): Define. (cygheap_pwdgrp::get_home): Declare. (cygheap_pwdgrp::get_shell): Declare. (cygheap_pwdgrp::get_gecos): Declare. * cygwin.ldif: New file. * ldap.cc (std_user_attr): New array, just defining the standard attributes. (group_attr): Add cygwinUnixGid. (user_attr): Convert to macro pointing to cygheap->pg.ldap_user_attr. (cygheap_pwdgrp::init_ldap_user_attr): New method. (cyg_ldap::fetch_ad_account): Call cygheap_pwdgrp::init_ldap_user_attr if user_attr initialization is required. Fix comment. (cyg_ldap::get_string_attribute): Implement taking attribute name as argument. * ldap.h: Drop unused macros. (cyg_ldap::get_gecos): Remove. (cyg_ldap::get_home): Remove. (cyg_ldap::get_shell): Remove. (cyg_ldap::get_string_attribute): Declare name argument variant public. * uinfo.cc (cygheap_user::ontherange): Fix indentation. (cygheap_pwdgrp::init): Initialize new home_scheme, shell_scheme and gecos_scheme members. Align comment. (NSS_NCMP): Define comparison macro. (NSS_CMP): Ditto. (cygheap_pwdgrp::nss_init_line): Use aforementioned macros throughout. Fix comment handling. Add db_home, db_shell and db_gecos handling. (fetch_from_description): New function to fetch XML-style attributes from (description) string. (fetch_from_path): New function to evaluate path string with wildcards. (cygheap_pwdgrp::get_home): New methods to fetch pw_dir value. (cygheap_pwdgrp::get_shell): Ditto for pw_shell. (cygheap_pwdgrp::get_gecos): Ditto for pw_gecos. (colon_to_semicolon): Move up. (pwdgrp::fetch_account_from_windows): Convert home, shell, gecos variables to char*. Drop statement breaking extended group info. Fetch home, shell and gecos values using new methods. Use fetch_from_description calls to fetch UNIX id and primary groups from SAM comment field. Accommodate uxid being a char* now. Accommodate the fact that extended info is malloc'ed, rather then alloca'ed. Create linebuf content as multibyte string. Create line buffer by just calling cstrdup.
75 lines
2.2 KiB
C++
75 lines
2.2 KiB
C++
/* ldap.h.
|
|
|
|
Copyright 2014 Red Hat, Inc.
|
|
|
|
This file is part of Cygwin.
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
details. */
|
|
|
|
#pragma once
|
|
|
|
#pragma push_macro ("DECLSPEC_IMPORT")
|
|
#undef DECLSPEC_IMPORT
|
|
#define DECLSPEC_IMPORT
|
|
#include <winldap.h>
|
|
#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 rootdse;
|
|
PLDAPMessage msg, entry;
|
|
PWCHAR *val;
|
|
PWCHAR *attr;
|
|
bool isAD;
|
|
PLDAPSearch srch_id;
|
|
PLDAPMessage srch_msg, srch_entry;
|
|
|
|
inline int map_ldaperr_to_errno (ULONG lerr);
|
|
inline int wait (cygthread *thr);
|
|
inline int connect (PCWSTR domain);
|
|
inline int search (PWCHAR base, PWCHAR filter, PWCHAR *attrs);
|
|
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), rootdse (NULL), msg (NULL), entry (NULL), val (NULL),
|
|
isAD (false), srch_id (NULL), srch_msg (NULL), srch_entry (NULL)
|
|
{}
|
|
~cyg_ldap () { close (); }
|
|
|
|
ULONG connect_ssl (PCWSTR domain);
|
|
ULONG connect_non_ssl (PCWSTR domain);
|
|
ULONG search_s (PWCHAR base, PWCHAR filter, PWCHAR *attrs);
|
|
ULONG next_page_s ();
|
|
|
|
operator PLDAP () const { return lh; }
|
|
int open (PCWSTR in_domain);
|
|
void close ();
|
|
bool fetch_ad_account (PSID sid, bool group, PCWSTR domain = NULL);
|
|
int enumerate_ad_accounts (PCWSTR domain, bool group);
|
|
int next_account (cygsid &sid);
|
|
uint32_t fetch_posix_offset_for_domain (PCWSTR domain);
|
|
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); }
|
|
/* 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);
|
|
};
|