s3:idmap_tdb2: move together code that belongs together in idmap_tdb2_alloc_load
[Samba.git] / nsswitch / libwbclient / wbclient.h
blob990cc52df79d1f7444fca0c44fd7185472957426
1 /*
2 Unix SMB/CIFS implementation.
4 Winbind client API
6 Copyright (C) Gerald (Jerry) Carter 2007
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 3 of the License, or (at your option) any later version.
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef _WBCLIENT_H
23 #define _WBCLIENT_H
25 #include <pwd.h>
26 #include <grp.h>
28 /* Define error types */
30 /**
31 * @brief Status codes returned from wbc functions
32 **/
34 enum _wbcErrType {
35 WBC_ERR_SUCCESS = 0, /**< Successful completion **/
36 WBC_ERR_NOT_IMPLEMENTED,/**< Function not implemented **/
37 WBC_ERR_UNKNOWN_FAILURE,/**< General failure **/
38 WBC_ERR_NO_MEMORY, /**< Memory allocation error **/
39 WBC_ERR_INVALID_SID, /**< Invalid SID format **/
40 WBC_ERR_INVALID_PARAM, /**< An Invalid parameter was supplied **/
41 WBC_ERR_WINBIND_NOT_AVAILABLE, /**< Winbind daemon is not available **/
42 WBC_ERR_DOMAIN_NOT_FOUND, /**< Domain is not trusted or cannot be found **/
43 WBC_ERR_INVALID_RESPONSE, /**< Winbind returned an invalid response **/
44 WBC_ERR_NSS_ERROR, /**< NSS_STATUS error **/
45 WBC_ERR_AUTH_ERROR, /**< Authentication failed **/
46 WBC_ERR_UNKNOWN_USER, /**< User account cannot be found */
47 WBC_ERR_UNKNOWN_GROUP, /**< Group account cannot be found */
48 WBC_ERR_PWD_CHANGE_FAILED /**< Password Change has failed */
51 typedef enum _wbcErrType wbcErr;
53 #define WBC_ERROR_IS_OK(x) ((x) == WBC_ERR_SUCCESS)
55 const char *wbcErrorString(wbcErr error);
57 /**
58 * @brief Some useful details about the wbclient library
60 * 0.1: Initial version
61 * 0.2: Added wbcRemoveUidMapping()
62 * Added wbcRemoveGidMapping()
63 **/
64 #define WBCLIENT_MAJOR_VERSION 0
65 #define WBCLIENT_MINOR_VERSION 2
66 #define WBCLIENT_VENDOR_VERSION "Samba libwbclient"
67 struct wbcLibraryDetails {
68 uint16_t major_version;
69 uint16_t minor_version;
70 const char *vendor_version;
73 /**
74 * @brief Some useful details about the running winbindd
76 **/
77 struct wbcInterfaceDetails {
78 uint32_t interface_version;
79 const char *winbind_version;
80 char winbind_separator;
81 const char *netbios_name;
82 const char *netbios_domain;
83 const char *dns_domain;
87 * Data types used by the Winbind Client API
90 #ifndef WBC_MAXSUBAUTHS
91 #define WBC_MAXSUBAUTHS 15 /* max sub authorities in a SID */
92 #endif
94 /**
95 * @brief Windows Security Identifier
97 **/
99 struct wbcDomainSid {
100 uint8_t sid_rev_num;
101 uint8_t num_auths;
102 uint8_t id_auth[6];
103 uint32_t sub_auths[WBC_MAXSUBAUTHS];
107 * @brief Security Identifier type
110 enum wbcSidType {
111 WBC_SID_NAME_USE_NONE=0,
112 WBC_SID_NAME_USER=1,
113 WBC_SID_NAME_DOM_GRP=2,
114 WBC_SID_NAME_DOMAIN=3,
115 WBC_SID_NAME_ALIAS=4,
116 WBC_SID_NAME_WKN_GRP=5,
117 WBC_SID_NAME_DELETED=6,
118 WBC_SID_NAME_INVALID=7,
119 WBC_SID_NAME_UNKNOWN=8,
120 WBC_SID_NAME_COMPUTER=9
124 * @brief Security Identifier with attributes
127 struct wbcSidWithAttr {
128 struct wbcDomainSid sid;
129 uint32_t attributes;
132 /* wbcSidWithAttr->attributes */
134 #define WBC_SID_ATTR_GROUP_MANDATORY 0x00000001
135 #define WBC_SID_ATTR_GROUP_ENABLED_BY_DEFAULT 0x00000002
136 #define WBC_SID_ATTR_GROUP_ENABLED 0x00000004
137 #define WBC_SID_ATTR_GROUP_OWNER 0x00000008
138 #define WBC_SID_ATTR_GROUP_USEFOR_DENY_ONLY 0x00000010
139 #define WBC_SID_ATTR_GROUP_RESOURCE 0x20000000
140 #define WBC_SID_ATTR_GROUP_LOGON_ID 0xC0000000
143 * @brief Windows GUID
147 struct wbcGuid {
148 uint32_t time_low;
149 uint16_t time_mid;
150 uint16_t time_hi_and_version;
151 uint8_t clock_seq[2];
152 uint8_t node[6];
156 * @brief Domain Information
159 struct wbcDomainInfo {
160 char *short_name;
161 char *dns_name;
162 struct wbcDomainSid sid;
163 uint32_t domain_flags;
164 uint32_t trust_flags;
165 uint32_t trust_type;
168 /* wbcDomainInfo->domain_flags */
170 #define WBC_DOMINFO_DOMAIN_UNKNOWN 0x00000000
171 #define WBC_DOMINFO_DOMAIN_NATIVE 0x00000001
172 #define WBC_DOMINFO_DOMAIN_AD 0x00000002
173 #define WBC_DOMINFO_DOMAIN_PRIMARY 0x00000004
174 #define WBC_DOMINFO_DOMAIN_OFFLINE 0x00000008
176 /* wbcDomainInfo->trust_flags */
178 #define WBC_DOMINFO_TRUST_TRANSITIVE 0x00000001
179 #define WBC_DOMINFO_TRUST_INCOMING 0x00000002
180 #define WBC_DOMINFO_TRUST_OUTGOING 0x00000004
182 /* wbcDomainInfo->trust_type */
184 #define WBC_DOMINFO_TRUSTTYPE_NONE 0x00000000
185 #define WBC_DOMINFO_TRUSTTYPE_FOREST 0x00000001
186 #define WBC_DOMINFO_TRUSTTYPE_IN_FOREST 0x00000002
187 #define WBC_DOMINFO_TRUSTTYPE_EXTERNAL 0x00000003
191 * @brief Auth User Parameters
194 struct wbcAuthUserParams {
195 const char *account_name;
196 const char *domain_name;
197 const char *workstation_name;
199 uint32_t flags;
201 uint32_t parameter_control;
203 enum wbcAuthUserLevel {
204 WBC_AUTH_USER_LEVEL_PLAIN = 1,
205 WBC_AUTH_USER_LEVEL_HASH = 2,
206 WBC_AUTH_USER_LEVEL_RESPONSE = 3
207 } level;
208 union {
209 const char *plaintext;
210 struct {
211 uint8_t nt_hash[16];
212 uint8_t lm_hash[16];
213 } hash;
214 struct {
215 uint8_t challenge[8];
216 uint32_t nt_length;
217 uint8_t *nt_data;
218 uint32_t lm_length;
219 uint8_t *lm_data;
220 } response;
221 } password;
225 * @brief Generic Blob
228 struct wbcBlob {
229 uint8_t *data;
230 size_t length;
234 * @brief Named Blob
237 struct wbcNamedBlob {
238 const char *name;
239 uint32_t flags;
240 struct wbcBlob blob;
244 * @brief Logon User Parameters
247 struct wbcLogonUserParams {
248 const char *username;
249 const char *password;
250 size_t num_blobs;
251 struct wbcNamedBlob *blobs;
255 * @brief ChangePassword Parameters
258 struct wbcChangePasswordParams {
259 const char *account_name;
260 const char *domain_name;
262 uint32_t flags;
264 enum wbcChangePasswordLevel {
265 WBC_CHANGE_PASSWORD_LEVEL_PLAIN = 1,
266 WBC_CHANGE_PASSWORD_LEVEL_RESPONSE = 2
267 } level;
269 union {
270 const char *plaintext;
271 struct {
272 uint32_t old_nt_hash_enc_length;
273 uint8_t *old_nt_hash_enc_data;
274 uint32_t old_lm_hash_enc_length;
275 uint8_t *old_lm_hash_enc_data;
276 } response;
277 } old_password;
278 union {
279 const char *plaintext;
280 struct {
281 uint32_t nt_length;
282 uint8_t *nt_data;
283 uint32_t lm_length;
284 uint8_t *lm_data;
285 } response;
286 } new_password;
289 /* wbcAuthUserParams->parameter_control */
291 #define WBC_MSV1_0_CLEARTEXT_PASSWORD_ALLOWED 0x00000002
292 #define WBC_MSV1_0_UPDATE_LOGON_STATISTICS 0x00000004
293 #define WBC_MSV1_0_RETURN_USER_PARAMETERS 0x00000008
294 #define WBC_MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT 0x00000020
295 #define WBC_MSV1_0_RETURN_PROFILE_PATH 0x00000200
296 #define WBC_MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT 0x00000800
298 /* wbcAuthUserParams->flags */
300 #define WBC_AUTH_PARAM_FLAGS_INTERACTIVE_LOGON 0x00000001
303 * @brief Auth User Information
305 * Some of the strings are maybe NULL
308 struct wbcAuthUserInfo {
309 uint32_t user_flags;
311 char *account_name;
312 char *user_principal;
313 char *full_name;
314 char *domain_name;
315 char *dns_domain_name;
317 uint32_t acct_flags;
318 uint8_t user_session_key[16];
319 uint8_t lm_session_key[8];
321 uint16_t logon_count;
322 uint16_t bad_password_count;
324 uint64_t logon_time;
325 uint64_t logoff_time;
326 uint64_t kickoff_time;
327 uint64_t pass_last_set_time;
328 uint64_t pass_can_change_time;
329 uint64_t pass_must_change_time;
331 char *logon_server;
332 char *logon_script;
333 char *profile_path;
334 char *home_directory;
335 char *home_drive;
338 * the 1st one is the account sid
339 * the 2nd one is the primary_group sid
340 * followed by the rest of the groups
342 uint32_t num_sids;
343 struct wbcSidWithAttr *sids;
347 * @brief Logon User Information
349 * Some of the strings are maybe NULL
352 struct wbcLogonUserInfo {
353 struct wbcAuthUserInfo *info;
354 size_t num_blobs;
355 struct wbcNamedBlob *blobs;
358 /* wbcAuthUserInfo->user_flags */
360 #define WBC_AUTH_USER_INFO_GUEST 0x00000001
361 #define WBC_AUTH_USER_INFO_NOENCRYPTION 0x00000002
362 #define WBC_AUTH_USER_INFO_CACHED_ACCOUNT 0x00000004
363 #define WBC_AUTH_USER_INFO_USED_LM_PASSWORD 0x00000008
364 #define WBC_AUTH_USER_INFO_EXTRA_SIDS 0x00000020
365 #define WBC_AUTH_USER_INFO_SUBAUTH_SESSION_KEY 0x00000040
366 #define WBC_AUTH_USER_INFO_SERVER_TRUST_ACCOUNT 0x00000080
367 #define WBC_AUTH_USER_INFO_NTLMV2_ENABLED 0x00000100
368 #define WBC_AUTH_USER_INFO_RESOURCE_GROUPS 0x00000200
369 #define WBC_AUTH_USER_INFO_PROFILE_PATH_RETURNED 0x00000400
370 #define WBC_AUTH_USER_INFO_GRACE_LOGON 0x01000000
372 /* wbcAuthUserInfo->acct_flags */
374 #define WBC_ACB_DISABLED 0x00000001 /* 1 User account disabled */
375 #define WBC_ACB_HOMDIRREQ 0x00000002 /* 1 Home directory required */
376 #define WBC_ACB_PWNOTREQ 0x00000004 /* 1 User password not required */
377 #define WBC_ACB_TEMPDUP 0x00000008 /* 1 Temporary duplicate account */
378 #define WBC_ACB_NORMAL 0x00000010 /* 1 Normal user account */
379 #define WBC_ACB_MNS 0x00000020 /* 1 MNS logon user account */
380 #define WBC_ACB_DOMTRUST 0x00000040 /* 1 Interdomain trust account */
381 #define WBC_ACB_WSTRUST 0x00000080 /* 1 Workstation trust account */
382 #define WBC_ACB_SVRTRUST 0x00000100 /* 1 Server trust account */
383 #define WBC_ACB_PWNOEXP 0x00000200 /* 1 User password does not expire */
384 #define WBC_ACB_AUTOLOCK 0x00000400 /* 1 Account auto locked */
385 #define WBC_ACB_ENC_TXT_PWD_ALLOWED 0x00000800 /* 1 Encryped text password is allowed */
386 #define WBC_ACB_SMARTCARD_REQUIRED 0x00001000 /* 1 Smart Card required */
387 #define WBC_ACB_TRUSTED_FOR_DELEGATION 0x00002000 /* 1 Trusted for Delegation */
388 #define WBC_ACB_NOT_DELEGATED 0x00004000 /* 1 Not delegated */
389 #define WBC_ACB_USE_DES_KEY_ONLY 0x00008000 /* 1 Use DES key only */
390 #define WBC_ACB_DONT_REQUIRE_PREAUTH 0x00010000 /* 1 Preauth not required */
391 #define WBC_ACB_PW_EXPIRED 0x00020000 /* 1 Password Expired */
392 #define WBC_ACB_NO_AUTH_DATA_REQD 0x00080000 /* 1 = No authorization data required */
394 struct wbcAuthErrorInfo {
395 uint32_t nt_status;
396 char *nt_string;
397 int32_t pam_error;
398 char *display_string;
402 * @brief User Password Policy Information
405 /* wbcUserPasswordPolicyInfo->password_properties */
407 #define WBC_DOMAIN_PASSWORD_COMPLEX 0x00000001
408 #define WBC_DOMAIN_PASSWORD_NO_ANON_CHANGE 0x00000002
409 #define WBC_DOMAIN_PASSWORD_NO_CLEAR_CHANGE 0x00000004
410 #define WBC_DOMAIN_PASSWORD_LOCKOUT_ADMINS 0x00000008
411 #define WBC_DOMAIN_PASSWORD_STORE_CLEARTEXT 0x00000010
412 #define WBC_DOMAIN_REFUSE_PASSWORD_CHANGE 0x00000020
414 struct wbcUserPasswordPolicyInfo {
415 uint32_t min_length_password;
416 uint32_t password_history;
417 uint32_t password_properties;
418 uint64_t expire;
419 uint64_t min_passwordage;
423 * @brief Change Password Reject Reason
426 enum wbcPasswordChangeRejectReason {
427 WBC_PWD_CHANGE_REJECT_OTHER=0,
428 WBC_PWD_CHANGE_REJECT_TOO_SHORT=1,
429 WBC_PWD_CHANGE_REJECT_IN_HISTORY=2,
430 WBC_PWD_CHANGE_REJECT_COMPLEXITY=5
434 * @brief Logoff User Parameters
437 struct wbcLogoffUserParams {
438 const char *username;
439 size_t num_blobs;
440 struct wbcNamedBlob *blobs;
443 /** @brief Credential cache log-on parameters
447 struct wbcCredentialCacheParams {
448 const char *account_name;
449 const char *domain_name;
450 enum wbcCredentialCacheLevel {
451 WBC_CREDENTIAL_CACHE_LEVEL_NTLMSSP = 1
452 } level;
453 size_t num_blobs;
454 struct wbcNamedBlob *blobs;
458 /** @brief Info returned by credential cache auth
462 struct wbcCredentialCacheInfo {
463 size_t num_blobs;
464 struct wbcNamedBlob *blobs;
468 * DomainControllerInfo struct
470 struct wbcDomainControllerInfo {
471 char *dc_name;
475 * DomainControllerInfoEx struct
477 struct wbcDomainControllerInfoEx {
478 const char *dc_unc;
479 const char *dc_address;
480 uint16_t dc_address_type;
481 struct wbcGuid *domain_guid;
482 const char *domain_name;
483 const char *forest_name;
484 uint32_t dc_flags;
485 const char *dc_site_name;
486 const char *client_site_name;
489 /**********************************************************
490 * Memory Management
491 **********************************************************/
494 * @brief Free library allocated memory
496 * @param *p Pointer to free
498 * @return void
500 void wbcFreeMemory(void*);
504 * Utility functions for dealing with SIDs
508 * @brief Convert a binary SID to a character string
510 * @param sid Binary Security Identifier
511 * @param **sid_string Resulting character string
513 * @return #wbcErr
515 wbcErr wbcSidToString(const struct wbcDomainSid *sid,
516 char **sid_string);
519 * @brief Convert a character string to a binary SID
521 * @param *str Character string in the form of S-...
522 * @param sid Resulting binary SID
524 * @return #wbcErr
526 wbcErr wbcStringToSid(const char *sid_string,
527 struct wbcDomainSid *sid);
530 * Utility functions for dealing with GUIDs
534 * @brief Convert a binary GUID to a character string
536 * @param guid Binary Guid
537 * @param **guid_string Resulting character string
539 * @return #wbcErr
541 wbcErr wbcGuidToString(const struct wbcGuid *guid,
542 char **guid_string);
545 * @brief Convert a character string to a binary GUID
547 * @param *str Character string
548 * @param guid Resulting binary GUID
550 * @return #wbcErr
552 wbcErr wbcStringToGuid(const char *guid_string,
553 struct wbcGuid *guid);
556 * @brief Ping winbindd to see if the daemon is running
558 * @return #wbcErr
560 wbcErr wbcPing(void);
562 wbcErr wbcLibraryDetails(struct wbcLibraryDetails **details);
564 wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **details);
566 /**********************************************************
567 * Name/SID conversion
568 **********************************************************/
571 * @brief Convert a domain and name to SID
573 * @param domain Domain name (possibly "")
574 * @param name User or group name
575 * @param *sid Pointer to the resolved domain SID
576 * @param *name_type Pointer to the SID type
578 * @return #wbcErr
580 wbcErr wbcLookupName(const char *dom_name,
581 const char *name,
582 struct wbcDomainSid *sid,
583 enum wbcSidType *name_type);
586 * @brief Convert a SID to a domain and name
588 * @param *sid Pointer to the domain SID to be resolved
589 * @param pdomain Resolved Domain name (possibly "")
590 * @param pname Resolved User or group name
591 * @param *pname_type Pointer to the resolved SID type
593 * @return #wbcErr
595 wbcErr wbcLookupSid(const struct wbcDomainSid *sid,
596 char **domain,
597 char **name,
598 enum wbcSidType *name_type);
601 * @brief Translate a collection of RIDs within a domain to names
603 wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
604 int num_rids,
605 uint32_t *rids,
606 const char **domain_name,
607 const char ***names,
608 enum wbcSidType **types);
611 * @brief Get the groups a user belongs to
613 wbcErr wbcLookupUserSids(const struct wbcDomainSid *user_sid,
614 bool domain_groups_only,
615 uint32_t *num_sids,
616 struct wbcDomainSid **sids);
619 * @brief Lists Users
621 wbcErr wbcListUsers(const char *domain_name,
622 uint32_t *num_users,
623 const char ***users);
626 * @brief Lists Groups
628 wbcErr wbcListGroups(const char *domain_name,
629 uint32_t *num_groups,
630 const char ***groups);
632 wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid,
633 char **pdomain,
634 char **pfullname,
635 enum wbcSidType *pname_type);
637 /**********************************************************
638 * SID/uid/gid Mappings
639 **********************************************************/
642 * @brief Convert a Windows SID to a Unix uid, allocating an uid if needed
644 * @param *sid Pointer to the domain SID to be resolved
645 * @param *puid Pointer to the resolved uid_t value
647 * @return #wbcErr
650 wbcErr wbcSidToUid(const struct wbcDomainSid *sid,
651 uid_t *puid);
654 * @brief Convert a Windows SID to a Unix uid if there already is a mapping
656 * @param *sid Pointer to the domain SID to be resolved
657 * @param *puid Pointer to the resolved uid_t value
659 * @return #wbcErr
662 wbcErr wbcQuerySidToUid(const struct wbcDomainSid *sid,
663 uid_t *puid);
666 * @brief Convert a Unix uid to a Windows SID, allocating a SID if needed
668 * @param uid Unix uid to be resolved
669 * @param *sid Pointer to the resolved domain SID
671 * @return #wbcErr
674 wbcErr wbcUidToSid(uid_t uid,
675 struct wbcDomainSid *sid);
678 * @brief Convert a Unix uid to a Windows SID if there already is a mapping
680 * @param uid Unix uid to be resolved
681 * @param *sid Pointer to the resolved domain SID
683 * @return #wbcErr
686 wbcErr wbcQueryUidToSid(uid_t uid,
687 struct wbcDomainSid *sid);
690 * @brief Convert a Windows SID to a Unix gid, allocating a gid if needed
692 * @param *sid Pointer to the domain SID to be resolved
693 * @param *pgid Pointer to the resolved gid_t value
695 * @return #wbcErr
698 wbcErr wbcSidToGid(const struct wbcDomainSid *sid,
699 gid_t *pgid);
702 * @brief Convert a Windows SID to a Unix gid if there already is a mapping
704 * @param *sid Pointer to the domain SID to be resolved
705 * @param *pgid Pointer to the resolved gid_t value
707 * @return #wbcErr
710 wbcErr wbcQuerySidToGid(const struct wbcDomainSid *sid,
711 gid_t *pgid);
714 * @brief Convert a Unix gid to a Windows SID, allocating a SID if needed
716 * @param gid Unix gid to be resolved
717 * @param *sid Pointer to the resolved domain SID
719 * @return #wbcErr
722 wbcErr wbcGidToSid(gid_t gid,
723 struct wbcDomainSid *sid);
726 * @brief Convert a Unix gid to a Windows SID if there already is a mapping
728 * @param gid Unix gid to be resolved
729 * @param *sid Pointer to the resolved domain SID
731 * @return #wbcErr
734 wbcErr wbcQueryGidToSid(gid_t gid,
735 struct wbcDomainSid *sid);
738 * @brief Obtain a new uid from Winbind
740 * @param *puid *pointer to the allocated uid
742 * @return #wbcErr
744 wbcErr wbcAllocateUid(uid_t *puid);
747 * @brief Obtain a new gid from Winbind
749 * @param *pgid Pointer to the allocated gid
751 * @return #wbcErr
753 wbcErr wbcAllocateGid(gid_t *pgid);
756 * @brief Set an user id mapping
758 * @param uid Uid of the desired mapping.
759 * @param *sid Pointer to the sid of the diresired mapping.
761 * @return #wbcErr
763 wbcErr wbcSetUidMapping(uid_t uid, const struct wbcDomainSid *sid);
766 * @brief Set a group id mapping
768 * @param gid Gid of the desired mapping.
769 * @param *sid Pointer to the sid of the diresired mapping.
771 * @return #wbcErr
773 wbcErr wbcSetGidMapping(gid_t gid, const struct wbcDomainSid *sid);
776 * @brief Remove a user id mapping
778 * @param uid Uid of the mapping to remove.
779 * @param *sid Pointer to the sid of the mapping to remove.
781 * @return #wbcErr
783 wbcErr wbcRemoveUidMapping(uid_t uid, const struct wbcDomainSid *sid);
786 * @brief Remove a group id mapping
788 * @param gid Gid of the mapping to remove.
789 * @param *sid Pointer to the sid of the mapping to remove.
791 * @return #wbcErr
793 wbcErr wbcRemoveGidMapping(gid_t gid, const struct wbcDomainSid *sid);
796 * @brief Set the highwater mark for allocated uids.
798 * @param uid_hwm The new uid highwater mark value
800 * @return #wbcErr
802 wbcErr wbcSetUidHwm(uid_t uid_hwm);
805 * @brief Set the highwater mark for allocated gids.
807 * @param gid_hwm The new gid highwater mark value
809 * @return #wbcErr
811 wbcErr wbcSetGidHwm(gid_t gid_hwm);
813 /**********************************************************
814 * NSS Lookup User/Group details
815 **********************************************************/
818 * @brief Fill in a struct passwd* for a domain user based
819 * on username
821 * @param *name Username to lookup
822 * @param **pwd Pointer to resulting struct passwd* from the query.
824 * @return #wbcErr
826 wbcErr wbcGetpwnam(const char *name, struct passwd **pwd);
829 * @brief Fill in a struct passwd* for a domain user based
830 * on uid
832 * @param uid Uid to lookup
833 * @param **pwd Pointer to resulting struct passwd* from the query.
835 * @return #wbcErr
837 wbcErr wbcGetpwuid(uid_t uid, struct passwd **pwd);
840 * @brief Fill in a struct passwd* for a domain user based
841 * on username
843 * @param *name Username to lookup
844 * @param **grp Pointer to resulting struct group* from the query.
846 * @return #wbcErr
848 wbcErr wbcGetgrnam(const char *name, struct group **grp);
851 * @brief Fill in a struct passwd* for a domain user based
852 * on uid
854 * @param gid Uid to lookup
855 * @param **grp Pointer to resulting struct group* from the query.
857 * @return #wbcErr
859 wbcErr wbcGetgrgid(gid_t gid, struct group **grp);
862 * @brief Reset the passwd iterator
864 * @return #wbcErr
866 wbcErr wbcSetpwent(void);
869 * @brief Close the passwd iterator
871 * @return #wbcErr
873 wbcErr wbcEndpwent(void);
876 * @brief Return the next struct passwd* entry from the pwent iterator
878 * @param **pwd Pointer to resulting struct passwd* from the query.
880 * @return #wbcErr
882 wbcErr wbcGetpwent(struct passwd **pwd);
885 * @brief Reset the group iterator
887 * @return #wbcErr
889 wbcErr wbcSetgrent(void);
892 * @brief Close the group iterator
894 * @return #wbcErr
896 wbcErr wbcEndgrent(void);
899 * @brief Return the next struct group* entry from the pwent iterator
901 * @param **grp Pointer to resulting struct group* from the query.
903 * @return #wbcErr
905 wbcErr wbcGetgrent(struct group **grp);
908 * @brief Return the next struct group* entry from the pwent iterator
910 * This is similar to #wbcGetgrent, just that the member list is empty
912 * @param **grp Pointer to resulting struct group* from the query.
914 * @return #wbcErr
916 wbcErr wbcGetgrlist(struct group **grp);
919 * @brief Return the unix group array belonging to the given user
921 * @param *account The given user name
922 * @param *num_groups Number of elements returned in the groups array
923 * @param **_groups Pointer to resulting gid_t array.
925 * @return #wbcErr
927 wbcErr wbcGetGroups(const char *account,
928 uint32_t *num_groups,
929 gid_t **_groups);
932 /**********************************************************
933 * Lookup Domain information
934 **********************************************************/
937 * @brief Lookup the current status of a trusted domain
939 * @param domain Domain to query
940 * @param *dinfo Pointer to returned domain_info struct
942 * @return #wbcErr
944 wbcErr wbcDomainInfo(const char *domain,
945 struct wbcDomainInfo **info);
948 * @brief Enumerate the domain trusts known by Winbind
950 * @param **domains Pointer to the allocated domain list array
951 * @param *num_domains Pointer to number of domains returned
953 * @return #wbcErr
955 wbcErr wbcListTrusts(struct wbcDomainInfo **domains,
956 size_t *num_domains);
958 /* Flags for wbcLookupDomainController */
960 #define WBC_LOOKUP_DC_FORCE_REDISCOVERY 0x00000001
961 #define WBC_LOOKUP_DC_DS_REQUIRED 0x00000010
962 #define WBC_LOOKUP_DC_DS_PREFERRED 0x00000020
963 #define WBC_LOOKUP_DC_GC_SERVER_REQUIRED 0x00000040
964 #define WBC_LOOKUP_DC_PDC_REQUIRED 0x00000080
965 #define WBC_LOOKUP_DC_BACKGROUND_ONLY 0x00000100
966 #define WBC_LOOKUP_DC_IP_REQUIRED 0x00000200
967 #define WBC_LOOKUP_DC_KDC_REQUIRED 0x00000400
968 #define WBC_LOOKUP_DC_TIMESERV_REQUIRED 0x00000800
969 #define WBC_LOOKUP_DC_WRITABLE_REQUIRED 0x00001000
970 #define WBC_LOOKUP_DC_GOOD_TIMESERV_PREFERRED 0x00002000
971 #define WBC_LOOKUP_DC_AVOID_SELF 0x00004000
972 #define WBC_LOOKUP_DC_ONLY_LDAP_NEEDED 0x00008000
973 #define WBC_LOOKUP_DC_IS_FLAT_NAME 0x00010000
974 #define WBC_LOOKUP_DC_IS_DNS_NAME 0x00020000
975 #define WBC_LOOKUP_DC_TRY_NEXTCLOSEST_SITE 0x00040000
976 #define WBC_LOOKUP_DC_DS_6_REQUIRED 0x00080000
977 #define WBC_LOOKUP_DC_RETURN_DNS_NAME 0x40000000
978 #define WBC_LOOKUP_DC_RETURN_FLAT_NAME 0x80000000
981 * @brief Enumerate the domain trusts known by Winbind
983 * @param domain Name of the domain to query for a DC
984 * @param flags Bit flags used to control the domain location query
985 * @param *dc_info Pointer to the returned domain controller information
987 * @return #wbcErr
989 wbcErr wbcLookupDomainController(const char *domain,
990 uint32_t flags,
991 struct wbcDomainControllerInfo **dc_info);
994 * @brief Get extended domain controller information
996 * @param domain Name of the domain to query for a DC
997 * @param guid Guid of the domain to query for a DC
998 * @param site Site of the domain to query for a DC
999 * @param flags Bit flags used to control the domain location query
1000 * @param *dc_info Pointer to the returned extended domain controller information
1002 * @return #wbcErr
1004 wbcErr wbcLookupDomainControllerEx(const char *domain,
1005 struct wbcGuid *guid,
1006 const char *site,
1007 uint32_t flags,
1008 struct wbcDomainControllerInfoEx **dc_info);
1010 /**********************************************************
1011 * Athenticate functions
1012 **********************************************************/
1015 * @brief Authenticate a username/password pair
1017 * @param username Name of user to authenticate
1018 * @param password Clear text password os user
1020 * @return #wbcErr
1022 wbcErr wbcAuthenticateUser(const char *username,
1023 const char *password);
1026 * @brief Authenticate with more detailed information
1028 * @param params Input parameters, WBC_AUTH_USER_LEVEL_HASH
1029 * is not supported yet
1030 * @param info Output details on WBC_ERR_SUCCESS
1031 * @param error Output details on WBC_ERR_AUTH_ERROR
1033 * @return #wbcErr
1035 wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params,
1036 struct wbcAuthUserInfo **info,
1037 struct wbcAuthErrorInfo **error);
1040 * @brief Logon a User
1042 * @param[in] params Pointer to a wbcLogonUserParams structure
1043 * @param[out] info Pointer to a pointer to a wbcLogonUserInfo structure
1044 * @param[out] error Pointer to a pointer to a wbcAuthErrorInfo structure
1045 * @param[out] policy Pointer to a pointer to a wbcUserPasswordPolicyInfo structure
1047 * @return #wbcErr
1049 wbcErr wbcLogonUser(const struct wbcLogonUserParams *params,
1050 struct wbcLogonUserInfo **info,
1051 struct wbcAuthErrorInfo **error,
1052 struct wbcUserPasswordPolicyInfo **policy);
1055 * @brief Trigger a logoff notification to Winbind for a specific user
1057 * @param username Name of user to remove from Winbind's list of
1058 * logged on users.
1059 * @param uid Uid assigned to the username
1060 * @param ccfilename Absolute path to the Krb5 credentials cache to
1061 * be removed
1063 * @return #wbcErr
1065 wbcErr wbcLogoffUser(const char *username,
1066 uid_t uid,
1067 const char *ccfilename);
1070 * @brief Trigger an extended logoff notification to Winbind for a specific user
1072 * @param params A wbcLogoffUserParams structure
1073 * @param error User output details on error
1075 * @return #wbcErr
1077 wbcErr wbcLogoffUserEx(const struct wbcLogoffUserParams *params,
1078 struct wbcAuthErrorInfo **error);
1081 * @brief Change a password for a user
1083 * @param username Name of user to authenticate
1084 * @param old_password Old clear text password of user
1085 * @param new_password New clear text password of user
1087 * @return #wbcErr
1089 wbcErr wbcChangeUserPassword(const char *username,
1090 const char *old_password,
1091 const char *new_password);
1094 * @brief Change a password for a user with more detailed information upon
1095 * failure
1097 * @param params Input parameters
1098 * @param error User output details on WBC_ERR_PWD_CHANGE_FAILED
1099 * @param reject_reason New password reject reason on WBC_ERR_PWD_CHANGE_FAILED
1100 * @param policy Password policy output details on WBC_ERR_PWD_CHANGE_FAILED
1102 * @return #wbcErr
1104 wbcErr wbcChangeUserPasswordEx(const struct wbcChangePasswordParams *params,
1105 struct wbcAuthErrorInfo **error,
1106 enum wbcPasswordChangeRejectReason *reject_reason,
1107 struct wbcUserPasswordPolicyInfo **policy);
1110 * @brief Authenticate a user with cached credentials
1112 * @param *params Pointer to a wbcCredentialCacheParams structure
1113 * @param **info Pointer to a pointer to a wbcCredentialCacheInfo structure
1114 * @param **error Pointer to a pointer to a wbcAuthErrorInfo structure
1116 * @return #wbcErr
1118 wbcErr wbcCredentialCache(struct wbcCredentialCacheParams *params,
1119 struct wbcCredentialCacheInfo **info,
1120 struct wbcAuthErrorInfo **error);
1122 /**********************************************************
1123 * Resolve functions
1124 **********************************************************/
1127 * @brief Resolve a NetbiosName via WINS
1129 * @param name Name to resolve
1130 * @param *ip Pointer to the ip address string
1132 * @return #wbcErr
1134 wbcErr wbcResolveWinsByName(const char *name, char **ip);
1137 * @brief Resolve an IP address via WINS into a NetbiosName
1139 * @param ip The ip address string
1140 * @param *name Pointer to the name
1142 * @return #wbcErr
1145 wbcErr wbcResolveWinsByIP(const char *ip, char **name);
1147 /**********************************************************
1148 * Trusted domain functions
1149 **********************************************************/
1152 * @brief Trigger a verification of the trust credentials of a specific domain
1154 * @param *domain The name of the domain, only NULL for the default domain is
1155 * supported yet. Other values than NULL will result in
1156 * WBC_ERR_NOT_IMPLEMENTED.
1157 * @param error Output details on WBC_ERR_AUTH_ERROR
1159 * @return #wbcErr
1161 wbcErr wbcCheckTrustCredentials(const char *domain,
1162 struct wbcAuthErrorInfo **error);
1164 /**********************************************************
1165 * Helper functions
1166 **********************************************************/
1169 * @brief Initialize a named blob and add to list of blobs
1171 * @param[in,out] num_blobs Pointer to the number of blobs
1172 * @param[in,out] blobs Pointer to an array of blobs
1173 * @param[in] name Name of the new named blob
1174 * @param[in] flags Flags of the new named blob
1175 * @param[in] data Blob data of new blob
1176 * @param[in] length Blob data length of new blob
1178 * @return #wbcErr
1180 wbcErr wbcAddNamedBlob(size_t *num_blobs,
1181 struct wbcNamedBlob **blobs,
1182 const char *name,
1183 uint32_t flags,
1184 uint8_t *data,
1185 size_t length);
1187 #endif /* _WBCLIENT_H */