3 This file is part of Cygwin.
5 This software is a copyrighted work licensed under the terms of the
6 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
11 #pragma push_macro ("DECLSPEC_IMPORT")
12 #undef DECLSPEC_IMPORT
13 #define DECLSPEC_IMPORT
16 #pragma pop_macro ("DECLSPEC_IMPORT")
21 PLDAPMessage msg
, entry
;
26 cygsid last_fetched_sid
;
28 inline int map_ldaperr_to_errno (ULONG lerr
);
29 inline int wait (cygthread
*thr
);
30 inline int connect (PCWSTR domain
);
31 inline int search (PWCHAR base
, ULONG scope
, PWCHAR filter
, PWCHAR
*attrs
);
32 inline int next_page ();
33 bool fetch_unix_sid_from_ad (uint32_t id
, cygsid
&sid
, bool group
);
34 PWCHAR
fetch_unix_name_from_rfc2307 (uint32_t id
, bool group
);
37 cyg_ldap () : lh (NULL
), def_context (NULL
), msg (NULL
), entry (NULL
),
38 val (NULL
), isAD (false), srch_id (NULL
),
39 last_fetched_sid (NO_SID
)
41 ~cyg_ldap () { close (); }
43 ULONG
connect_ssl (PCWSTR domain
);
44 ULONG
connect_non_ssl (PCWSTR domain
);
45 ULONG
search_s (PWCHAR base
, ULONG scope
, PWCHAR filter
, PWCHAR
*attrs
);
48 bool is_open () const { return !!lh
; }
49 operator PLDAP () const { return lh
; }
50 int open (PCWSTR in_domain
);
52 PWCHAR
get_string_attribute (PCWSTR name
);
53 uint32_t get_num_attribute (PCWSTR name
);
54 bool fetch_ad_account (PSID sid
, bool group
, PCWSTR domain
= NULL
);
55 int enumerate_ad_accounts (PCWSTR domain
, bool group
);
56 int next_account (cygsid
&sid
);
57 uint32_t fetch_posix_offset_for_domain (PCWSTR domain
);
58 uid_t
remap_uid (uid_t uid
);
59 gid_t
remap_gid (gid_t gid
);
61 gid_t
get_primary_gid () { return get_num_attribute (L
"primaryGroupID"); }
62 gid_t
get_unix_uid () { return get_num_attribute (L
"uidNumber"); }
63 PWCHAR
get_account_name ()
64 { return get_string_attribute (L
"sAMAccountName"); }
65 gid_t
get_unix_gid () { return get_num_attribute (L
"gidNumber"); }
66 PWCHAR
get_profile_path ()
67 { return get_string_attribute (L
"profilePath"); }