s3: add an option "kernel share modes" to be able to switch off using kernel flocks
[Samba/gebeck_regimport.git] / nsswitch / libwbclient / wbclient.h
blobcb70cbd51386f45d856848e736d8e1df55dc4f2b
1 /*
2 Unix SMB/CIFS implementation.
4 Winbind client API
6 Copyright (C) Gerald (Jerry) Carter 2007
7 Copyright (C) Volker Lendecke 2009
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 3 of the License, or (at your option) any later version.
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef _WBCLIENT_H
24 #define _WBCLIENT_H
26 #include <pwd.h>
27 #include <grp.h>
29 /* Define error types */
31 /**
32 * @brief Status codes returned from wbc functions
33 **/
35 enum _wbcErrType {
36 WBC_ERR_SUCCESS = 0, /**< Successful completion **/
37 WBC_ERR_NOT_IMPLEMENTED,/**< Function not implemented **/
38 WBC_ERR_UNKNOWN_FAILURE,/**< General failure **/
39 WBC_ERR_NO_MEMORY, /**< Memory allocation error **/
40 WBC_ERR_INVALID_SID, /**< Invalid SID format **/
41 WBC_ERR_INVALID_PARAM, /**< An Invalid parameter was supplied **/
42 WBC_ERR_WINBIND_NOT_AVAILABLE, /**< Winbind daemon is not available **/
43 WBC_ERR_DOMAIN_NOT_FOUND, /**< Domain is not trusted or cannot be found **/
44 WBC_ERR_INVALID_RESPONSE, /**< Winbind returned an invalid response **/
45 WBC_ERR_NSS_ERROR, /**< NSS_STATUS error **/
46 WBC_ERR_AUTH_ERROR, /**< Authentication failed **/
47 WBC_ERR_UNKNOWN_USER, /**< User account cannot be found */
48 WBC_ERR_UNKNOWN_GROUP, /**< Group account cannot be found */
49 WBC_ERR_PWD_CHANGE_FAILED /**< Password Change has failed */
52 typedef enum _wbcErrType wbcErr;
54 #define WBC_ERROR_IS_OK(x) ((x) == WBC_ERR_SUCCESS)
56 const char *wbcErrorString(wbcErr error);
58 /**
59 * @brief Some useful details about the wbclient library
61 * 0.1: Initial version
62 * 0.2: Added wbcRemoveUidMapping()
63 * Added wbcRemoveGidMapping()
64 * 0.3: Added wbcGetpwsid()
65 * Added wbcGetSidAliases()
66 * 0.4: Added wbcSidTypeString()
67 * 0.5: Added wbcChangeTrustCredentials()
68 * 0.6: Made struct wbcInterfaceDetails char* members non-const
69 * 0.7: Added wbcSidToStringBuf()
70 * 0.8: Added wbcSidsToUnixIds() and wbcLookupSids()
71 * 0.9: Added support for WBC_ID_TYPE_BOTH
72 * 0.10: Added wbcPingDc2()
73 **/
74 #define WBCLIENT_MAJOR_VERSION 0
75 #define WBCLIENT_MINOR_VERSION 10
76 #define WBCLIENT_VENDOR_VERSION "Samba libwbclient"
77 struct wbcLibraryDetails {
78 uint16_t major_version;
79 uint16_t minor_version;
80 const char *vendor_version;
83 /**
84 * @brief Some useful details about the running winbindd
86 **/
87 struct wbcInterfaceDetails {
88 uint32_t interface_version;
89 char *winbind_version;
90 char winbind_separator;
91 char *netbios_name;
92 char *netbios_domain;
93 char *dns_domain;
97 * Data types used by the Winbind Client API
100 #ifndef WBC_MAXSUBAUTHS
101 #define WBC_MAXSUBAUTHS 15 /* max sub authorities in a SID */
102 #endif
105 * @brief Windows Security Identifier
109 struct wbcDomainSid {
110 uint8_t sid_rev_num;
111 uint8_t num_auths;
112 uint8_t id_auth[6];
113 uint32_t sub_auths[WBC_MAXSUBAUTHS];
117 * @brief Security Identifier type
120 enum wbcSidType {
121 WBC_SID_NAME_USE_NONE=0,
122 WBC_SID_NAME_USER=1,
123 WBC_SID_NAME_DOM_GRP=2,
124 WBC_SID_NAME_DOMAIN=3,
125 WBC_SID_NAME_ALIAS=4,
126 WBC_SID_NAME_WKN_GRP=5,
127 WBC_SID_NAME_DELETED=6,
128 WBC_SID_NAME_INVALID=7,
129 WBC_SID_NAME_UNKNOWN=8,
130 WBC_SID_NAME_COMPUTER=9
134 * @brief Security Identifier with attributes
137 struct wbcSidWithAttr {
138 struct wbcDomainSid sid;
139 uint32_t attributes;
142 /* wbcSidWithAttr->attributes */
144 #define WBC_SID_ATTR_GROUP_MANDATORY 0x00000001
145 #define WBC_SID_ATTR_GROUP_ENABLED_BY_DEFAULT 0x00000002
146 #define WBC_SID_ATTR_GROUP_ENABLED 0x00000004
147 #define WBC_SID_ATTR_GROUP_OWNER 0x00000008
148 #define WBC_SID_ATTR_GROUP_USEFOR_DENY_ONLY 0x00000010
149 #define WBC_SID_ATTR_GROUP_RESOURCE 0x20000000
150 #define WBC_SID_ATTR_GROUP_LOGON_ID 0xC0000000
153 * @brief Windows GUID
157 struct wbcGuid {
158 uint32_t time_low;
159 uint16_t time_mid;
160 uint16_t time_hi_and_version;
161 uint8_t clock_seq[2];
162 uint8_t node[6];
166 * @brief Domain Information
169 struct wbcDomainInfo {
170 char *short_name;
171 char *dns_name;
172 struct wbcDomainSid sid;
173 uint32_t domain_flags;
174 uint32_t trust_flags;
175 uint32_t trust_type;
178 /* wbcDomainInfo->domain_flags */
180 #define WBC_DOMINFO_DOMAIN_UNKNOWN 0x00000000
181 #define WBC_DOMINFO_DOMAIN_NATIVE 0x00000001
182 #define WBC_DOMINFO_DOMAIN_AD 0x00000002
183 #define WBC_DOMINFO_DOMAIN_PRIMARY 0x00000004
184 #define WBC_DOMINFO_DOMAIN_OFFLINE 0x00000008
186 /* wbcDomainInfo->trust_flags */
188 #define WBC_DOMINFO_TRUST_TRANSITIVE 0x00000001
189 #define WBC_DOMINFO_TRUST_INCOMING 0x00000002
190 #define WBC_DOMINFO_TRUST_OUTGOING 0x00000004
192 /* wbcDomainInfo->trust_type */
194 #define WBC_DOMINFO_TRUSTTYPE_NONE 0x00000000
195 #define WBC_DOMINFO_TRUSTTYPE_FOREST 0x00000001
196 #define WBC_DOMINFO_TRUSTTYPE_IN_FOREST 0x00000002
197 #define WBC_DOMINFO_TRUSTTYPE_EXTERNAL 0x00000003
200 * @brief Auth User Parameters
203 struct wbcAuthUserParams {
204 const char *account_name;
205 const char *domain_name;
206 const char *workstation_name;
208 uint32_t flags;
210 uint32_t parameter_control;
212 enum wbcAuthUserLevel {
213 WBC_AUTH_USER_LEVEL_PLAIN = 1,
214 WBC_AUTH_USER_LEVEL_HASH = 2,
215 WBC_AUTH_USER_LEVEL_RESPONSE = 3
216 } level;
217 union {
218 const char *plaintext;
219 struct {
220 uint8_t nt_hash[16];
221 uint8_t lm_hash[16];
222 } hash;
223 struct {
224 uint8_t challenge[8];
225 uint32_t nt_length;
226 uint8_t *nt_data;
227 uint32_t lm_length;
228 uint8_t *lm_data;
229 } response;
230 } password;
234 * @brief Generic Blob
237 struct wbcBlob {
238 uint8_t *data;
239 size_t length;
243 * @brief Named Blob
246 struct wbcNamedBlob {
247 const char *name;
248 uint32_t flags;
249 struct wbcBlob blob;
253 * @brief Logon User Parameters
256 struct wbcLogonUserParams {
257 const char *username;
258 const char *password;
259 size_t num_blobs;
260 struct wbcNamedBlob *blobs;
264 * @brief ChangePassword Parameters
267 struct wbcChangePasswordParams {
268 const char *account_name;
269 const char *domain_name;
271 uint32_t flags;
273 enum wbcChangePasswordLevel {
274 WBC_CHANGE_PASSWORD_LEVEL_PLAIN = 1,
275 WBC_CHANGE_PASSWORD_LEVEL_RESPONSE = 2
276 } level;
278 union {
279 const char *plaintext;
280 struct {
281 uint32_t old_nt_hash_enc_length;
282 uint8_t *old_nt_hash_enc_data;
283 uint32_t old_lm_hash_enc_length;
284 uint8_t *old_lm_hash_enc_data;
285 } response;
286 } old_password;
287 union {
288 const char *plaintext;
289 struct {
290 uint32_t nt_length;
291 uint8_t *nt_data;
292 uint32_t lm_length;
293 uint8_t *lm_data;
294 } response;
295 } new_password;
298 /* wbcAuthUserParams->parameter_control */
300 #define WBC_MSV1_0_CLEARTEXT_PASSWORD_ALLOWED 0x00000002
301 #define WBC_MSV1_0_UPDATE_LOGON_STATISTICS 0x00000004
302 #define WBC_MSV1_0_RETURN_USER_PARAMETERS 0x00000008
303 #define WBC_MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT 0x00000020
304 #define WBC_MSV1_0_RETURN_PROFILE_PATH 0x00000200
305 #define WBC_MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT 0x00000800
307 /* wbcAuthUserParams->flags */
309 #define WBC_AUTH_PARAM_FLAGS_INTERACTIVE_LOGON 0x00000001
312 * @brief Auth User Information
314 * Some of the strings are maybe NULL
317 struct wbcAuthUserInfo {
318 uint32_t user_flags;
320 char *account_name;
321 char *user_principal;
322 char *full_name;
323 char *domain_name;
324 char *dns_domain_name;
326 uint32_t acct_flags;
327 uint8_t user_session_key[16];
328 uint8_t lm_session_key[8];
330 uint16_t logon_count;
331 uint16_t bad_password_count;
333 uint64_t logon_time;
334 uint64_t logoff_time;
335 uint64_t kickoff_time;
336 uint64_t pass_last_set_time;
337 uint64_t pass_can_change_time;
338 uint64_t pass_must_change_time;
340 char *logon_server;
341 char *logon_script;
342 char *profile_path;
343 char *home_directory;
344 char *home_drive;
347 * the 1st one is the account sid
348 * the 2nd one is the primary_group sid
349 * followed by the rest of the groups
351 uint32_t num_sids;
352 struct wbcSidWithAttr *sids;
356 * @brief Logon User Information
358 * Some of the strings are maybe NULL
361 struct wbcLogonUserInfo {
362 struct wbcAuthUserInfo *info;
363 size_t num_blobs;
364 struct wbcNamedBlob *blobs;
367 /* wbcAuthUserInfo->user_flags */
369 #define WBC_AUTH_USER_INFO_GUEST 0x00000001
370 #define WBC_AUTH_USER_INFO_NOENCRYPTION 0x00000002
371 #define WBC_AUTH_USER_INFO_CACHED_ACCOUNT 0x00000004
372 #define WBC_AUTH_USER_INFO_USED_LM_PASSWORD 0x00000008
373 #define WBC_AUTH_USER_INFO_EXTRA_SIDS 0x00000020
374 #define WBC_AUTH_USER_INFO_SUBAUTH_SESSION_KEY 0x00000040
375 #define WBC_AUTH_USER_INFO_SERVER_TRUST_ACCOUNT 0x00000080
376 #define WBC_AUTH_USER_INFO_NTLMV2_ENABLED 0x00000100
377 #define WBC_AUTH_USER_INFO_RESOURCE_GROUPS 0x00000200
378 #define WBC_AUTH_USER_INFO_PROFILE_PATH_RETURNED 0x00000400
379 #define WBC_AUTH_USER_INFO_GRACE_LOGON 0x01000000
381 /* wbcAuthUserInfo->acct_flags */
383 #define WBC_ACB_DISABLED 0x00000001 /* 1 User account disabled */
384 #define WBC_ACB_HOMDIRREQ 0x00000002 /* 1 Home directory required */
385 #define WBC_ACB_PWNOTREQ 0x00000004 /* 1 User password not required */
386 #define WBC_ACB_TEMPDUP 0x00000008 /* 1 Temporary duplicate account */
387 #define WBC_ACB_NORMAL 0x00000010 /* 1 Normal user account */
388 #define WBC_ACB_MNS 0x00000020 /* 1 MNS logon user account */
389 #define WBC_ACB_DOMTRUST 0x00000040 /* 1 Interdomain trust account */
390 #define WBC_ACB_WSTRUST 0x00000080 /* 1 Workstation trust account */
391 #define WBC_ACB_SVRTRUST 0x00000100 /* 1 Server trust account */
392 #define WBC_ACB_PWNOEXP 0x00000200 /* 1 User password does not expire */
393 #define WBC_ACB_AUTOLOCK 0x00000400 /* 1 Account auto locked */
394 #define WBC_ACB_ENC_TXT_PWD_ALLOWED 0x00000800 /* 1 Encryped text password is allowed */
395 #define WBC_ACB_SMARTCARD_REQUIRED 0x00001000 /* 1 Smart Card required */
396 #define WBC_ACB_TRUSTED_FOR_DELEGATION 0x00002000 /* 1 Trusted for Delegation */
397 #define WBC_ACB_NOT_DELEGATED 0x00004000 /* 1 Not delegated */
398 #define WBC_ACB_USE_DES_KEY_ONLY 0x00008000 /* 1 Use DES key only */
399 #define WBC_ACB_DONT_REQUIRE_PREAUTH 0x00010000 /* 1 Preauth not required */
400 #define WBC_ACB_PW_EXPIRED 0x00020000 /* 1 Password Expired */
401 #define WBC_ACB_NO_AUTH_DATA_REQD 0x00080000 /* 1 = No authorization data required */
403 struct wbcAuthErrorInfo {
404 uint32_t nt_status;
405 char *nt_string;
406 int32_t pam_error;
407 char *display_string;
411 * @brief User Password Policy Information
414 /* wbcUserPasswordPolicyInfo->password_properties */
416 #define WBC_DOMAIN_PASSWORD_COMPLEX 0x00000001
417 #define WBC_DOMAIN_PASSWORD_NO_ANON_CHANGE 0x00000002
418 #define WBC_DOMAIN_PASSWORD_NO_CLEAR_CHANGE 0x00000004
419 #define WBC_DOMAIN_PASSWORD_LOCKOUT_ADMINS 0x00000008
420 #define WBC_DOMAIN_PASSWORD_STORE_CLEARTEXT 0x00000010
421 #define WBC_DOMAIN_REFUSE_PASSWORD_CHANGE 0x00000020
423 struct wbcUserPasswordPolicyInfo {
424 uint32_t min_length_password;
425 uint32_t password_history;
426 uint32_t password_properties;
427 uint64_t expire;
428 uint64_t min_passwordage;
432 * @brief Change Password Reject Reason
435 enum wbcPasswordChangeRejectReason {
436 WBC_PWD_CHANGE_NO_ERROR=0,
437 WBC_PWD_CHANGE_PASSWORD_TOO_SHORT=1,
438 WBC_PWD_CHANGE_PWD_IN_HISTORY=2,
439 WBC_PWD_CHANGE_USERNAME_IN_PASSWORD=3,
440 WBC_PWD_CHANGE_FULLNAME_IN_PASSWORD=4,
441 WBC_PWD_CHANGE_NOT_COMPLEX=5,
442 WBC_PWD_CHANGE_MACHINE_NOT_DEFAULT=6,
443 WBC_PWD_CHANGE_FAILED_BY_FILTER=7,
444 WBC_PWD_CHANGE_PASSWORD_TOO_LONG=8
447 /* Note: this defines exist for compatibility reasons with existing code */
448 #define WBC_PWD_CHANGE_REJECT_OTHER WBC_PWD_CHANGE_NO_ERROR
449 #define WBC_PWD_CHANGE_REJECT_TOO_SHORT WBC_PWD_CHANGE_PASSWORD_TOO_SHORT
450 #define WBC_PWD_CHANGE_REJECT_IN_HISTORY WBC_PWD_CHANGE_PWD_IN_HISTORY
451 #define WBC_PWD_CHANGE_REJECT_COMPLEXITY WBC_PWD_CHANGE_NOT_COMPLEX
454 * @brief Logoff User Parameters
457 struct wbcLogoffUserParams {
458 const char *username;
459 size_t num_blobs;
460 struct wbcNamedBlob *blobs;
463 /** @brief Credential cache log-on parameters
467 struct wbcCredentialCacheParams {
468 const char *account_name;
469 const char *domain_name;
470 enum wbcCredentialCacheLevel {
471 WBC_CREDENTIAL_CACHE_LEVEL_NTLMSSP = 1
472 } level;
473 size_t num_blobs;
474 struct wbcNamedBlob *blobs;
478 /** @brief Info returned by credential cache auth
482 struct wbcCredentialCacheInfo {
483 size_t num_blobs;
484 struct wbcNamedBlob *blobs;
488 * DomainControllerInfo struct
490 struct wbcDomainControllerInfo {
491 char *dc_name;
495 * DomainControllerInfoEx struct
497 struct wbcDomainControllerInfoEx {
498 const char *dc_unc;
499 const char *dc_address;
500 uint16_t dc_address_type;
501 struct wbcGuid *domain_guid;
502 const char *domain_name;
503 const char *forest_name;
504 uint32_t dc_flags;
505 const char *dc_site_name;
506 const char *client_site_name;
509 /**********************************************************
510 * Memory Management
511 **********************************************************/
514 * @brief Free library allocated memory
516 * @param * Pointer to free
518 * @return void
520 void wbcFreeMemory(void*);
524 * Utility functions for dealing with SIDs
528 * @brief Get a string representation of the SID type
530 * @param type type of the SID
532 * @return string representation of the SID type
534 const char* wbcSidTypeString(enum wbcSidType type);
536 #define WBC_SID_STRING_BUFLEN (15*11+25)
539 * @brief Print a sid into a buffer
541 * @param sid Binary Security Identifier
542 * @param buf Target buffer
543 * @param buflen Target buffer length
545 * @return Resulting string length.
547 int wbcSidToStringBuf(const struct wbcDomainSid *sid, char *buf, int buflen);
550 * @brief Convert a binary SID to a character string
552 * @param sid Binary Security Identifier
553 * @param **sid_string Resulting character string
555 * @return #wbcErr
557 wbcErr wbcSidToString(const struct wbcDomainSid *sid,
558 char **sid_string);
561 * @brief Convert a character string to a binary SID
563 * @param *sid_string Character string in the form of S-...
564 * @param sid Resulting binary SID
566 * @return #wbcErr
568 wbcErr wbcStringToSid(const char *sid_string,
569 struct wbcDomainSid *sid);
572 * Utility functions for dealing with GUIDs
576 * @brief Convert a binary GUID to a character string
578 * @param guid Binary Guid
579 * @param **guid_string Resulting character string
581 * @return #wbcErr
583 wbcErr wbcGuidToString(const struct wbcGuid *guid,
584 char **guid_string);
587 * @brief Convert a character string to a binary GUID
589 * @param *guid_string Character string
590 * @param guid Resulting binary GUID
592 * @return #wbcErr
594 wbcErr wbcStringToGuid(const char *guid_string,
595 struct wbcGuid *guid);
598 * @brief Ping winbindd to see if the daemon is running
600 * @return #wbcErr
602 wbcErr wbcPing(void);
604 wbcErr wbcLibraryDetails(struct wbcLibraryDetails **details);
606 wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **details);
608 /**********************************************************
609 * Name/SID conversion
610 **********************************************************/
613 * @brief Convert a domain and name to SID
615 * @param dom_name Domain name (possibly "")
616 * @param name User or group name
617 * @param *sid Pointer to the resolved domain SID
618 * @param *name_type Pointer to the SID type
620 * @return #wbcErr
622 wbcErr wbcLookupName(const char *dom_name,
623 const char *name,
624 struct wbcDomainSid *sid,
625 enum wbcSidType *name_type);
628 * @brief Convert a SID to a domain and name
630 * @param *sid Pointer to the domain SID to be resolved
631 * @param domain Resolved Domain name (possibly "")
632 * @param name Resolved User or group name
633 * @param *name_type Pointer to the resolved SID type
635 * @return #wbcErr
637 wbcErr wbcLookupSid(const struct wbcDomainSid *sid,
638 char **domain,
639 char **name,
640 enum wbcSidType *name_type);
642 struct wbcTranslatedName {
643 enum wbcSidType type;
644 char *name;
645 int domain_index;
648 wbcErr wbcLookupSids(const struct wbcDomainSid *sids, int num_sids,
649 struct wbcDomainInfo **domains, int *num_domains,
650 struct wbcTranslatedName **names);
653 * @brief Translate a collection of RIDs within a domain to names
655 wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
656 int num_rids,
657 uint32_t *rids,
658 const char **domain_name,
659 const char ***names,
660 enum wbcSidType **types);
663 * @brief Get the groups a user belongs to
665 wbcErr wbcLookupUserSids(const struct wbcDomainSid *user_sid,
666 bool domain_groups_only,
667 uint32_t *num_sids,
668 struct wbcDomainSid **sids);
671 * @brief Get alias membership for sids
673 wbcErr wbcGetSidAliases(const struct wbcDomainSid *dom_sid,
674 struct wbcDomainSid *sids,
675 uint32_t num_sids,
676 uint32_t **alias_rids,
677 uint32_t *num_alias_rids);
680 * @brief Lists Users
682 wbcErr wbcListUsers(const char *domain_name,
683 uint32_t *num_users,
684 const char ***users);
687 * @brief Lists Groups
689 wbcErr wbcListGroups(const char *domain_name,
690 uint32_t *num_groups,
691 const char ***groups);
693 wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid,
694 char **pdomain,
695 char **pfullname,
696 enum wbcSidType *pname_type);
698 /**********************************************************
699 * SID/uid/gid Mappings
700 **********************************************************/
703 * @brief Convert a Windows SID to a Unix uid, allocating an uid if needed
705 * @param *sid Pointer to the domain SID to be resolved
706 * @param *puid Pointer to the resolved uid_t value
708 * @return #wbcErr
711 wbcErr wbcSidToUid(const struct wbcDomainSid *sid,
712 uid_t *puid);
715 * @brief Convert a Windows SID to a Unix uid if there already is a mapping
717 * @param *sid Pointer to the domain SID to be resolved
718 * @param *puid Pointer to the resolved uid_t value
720 * @return #wbcErr
723 wbcErr wbcQuerySidToUid(const struct wbcDomainSid *sid,
724 uid_t *puid);
727 * @brief Convert a Unix uid to a Windows SID, allocating a SID if needed
729 * @param uid Unix uid to be resolved
730 * @param *sid Pointer to the resolved domain SID
732 * @return #wbcErr
735 wbcErr wbcUidToSid(uid_t uid,
736 struct wbcDomainSid *sid);
739 * @brief Convert a Unix uid to a Windows SID if there already is a mapping
741 * @param uid Unix uid to be resolved
742 * @param *sid Pointer to the resolved domain SID
744 * @return #wbcErr
747 wbcErr wbcQueryUidToSid(uid_t uid,
748 struct wbcDomainSid *sid);
751 * @brief Convert a Windows SID to a Unix gid, allocating a gid if needed
753 * @param *sid Pointer to the domain SID to be resolved
754 * @param *pgid Pointer to the resolved gid_t value
756 * @return #wbcErr
759 wbcErr wbcSidToGid(const struct wbcDomainSid *sid,
760 gid_t *pgid);
763 * @brief Convert a Windows SID to a Unix gid if there already is a mapping
765 * @param *sid Pointer to the domain SID to be resolved
766 * @param *pgid Pointer to the resolved gid_t value
768 * @return #wbcErr
771 wbcErr wbcQuerySidToGid(const struct wbcDomainSid *sid,
772 gid_t *pgid);
775 * @brief Convert a Unix gid to a Windows SID, allocating a SID if needed
777 * @param gid Unix gid to be resolved
778 * @param *sid Pointer to the resolved domain SID
780 * @return #wbcErr
783 wbcErr wbcGidToSid(gid_t gid,
784 struct wbcDomainSid *sid);
787 * @brief Convert a Unix gid to a Windows SID if there already is a mapping
789 * @param gid Unix gid to be resolved
790 * @param *sid Pointer to the resolved domain SID
792 * @return #wbcErr
795 wbcErr wbcQueryGidToSid(gid_t gid,
796 struct wbcDomainSid *sid);
798 enum wbcIdType {
799 WBC_ID_TYPE_NOT_SPECIFIED,
800 WBC_ID_TYPE_UID,
801 WBC_ID_TYPE_GID,
802 WBC_ID_TYPE_BOTH
805 union wbcUnixIdContainer {
806 uid_t uid;
807 gid_t gid;
810 struct wbcUnixId {
811 enum wbcIdType type;
812 union wbcUnixIdContainer id;
816 * @brief Convert a list of sids to unix ids
818 * @param sids Pointer to an array of SIDs to convert
819 * @param num_sids Number of SIDs
820 * @param ids Preallocated output array for translated IDs
822 * @return #wbcErr
825 wbcErr wbcSidsToUnixIds(const struct wbcDomainSid *sids, uint32_t num_sids,
826 struct wbcUnixId *ids);
829 * @brief Obtain a new uid from Winbind
831 * @param *puid *pointer to the allocated uid
833 * @return #wbcErr
835 wbcErr wbcAllocateUid(uid_t *puid);
838 * @brief Obtain a new gid from Winbind
840 * @param *pgid Pointer to the allocated gid
842 * @return #wbcErr
844 wbcErr wbcAllocateGid(gid_t *pgid);
847 * @brief Set an user id mapping
849 * @param uid Uid of the desired mapping.
850 * @param *sid Pointer to the sid of the diresired mapping.
852 * @return #wbcErr
854 * @deprecated This method is not impemented any more and should
855 * be removed in the next major version change.
857 wbcErr wbcSetUidMapping(uid_t uid, const struct wbcDomainSid *sid);
860 * @brief Set a group id mapping
862 * @param gid Gid of the desired mapping.
863 * @param *sid Pointer to the sid of the diresired mapping.
865 * @return #wbcErr
867 * @deprecated This method is not impemented any more and should
868 * be removed in the next major version change.
870 wbcErr wbcSetGidMapping(gid_t gid, const struct wbcDomainSid *sid);
873 * @brief Remove a user id mapping
875 * @param uid Uid of the mapping to remove.
876 * @param *sid Pointer to the sid of the mapping to remove.
878 * @return #wbcErr
880 * @deprecated This method is not impemented any more and should
881 * be removed in the next major version change.
883 wbcErr wbcRemoveUidMapping(uid_t uid, const struct wbcDomainSid *sid);
886 * @brief Remove a group id mapping
888 * @param gid Gid of the mapping to remove.
889 * @param *sid Pointer to the sid of the mapping to remove.
891 * @return #wbcErr
893 * @deprecated This method is not impemented any more and should
894 * be removed in the next major version change.
896 wbcErr wbcRemoveGidMapping(gid_t gid, const struct wbcDomainSid *sid);
899 * @brief Set the highwater mark for allocated uids.
901 * @param uid_hwm The new uid highwater mark value
903 * @return #wbcErr
905 * @deprecated This method is not impemented any more and should
906 * be removed in the next major version change.
908 wbcErr wbcSetUidHwm(uid_t uid_hwm);
911 * @brief Set the highwater mark for allocated gids.
913 * @param gid_hwm The new gid highwater mark value
915 * @return #wbcErr
917 * @deprecated This method is not impemented any more and should
918 * be removed in the next major version change.
920 wbcErr wbcSetGidHwm(gid_t gid_hwm);
922 /**********************************************************
923 * NSS Lookup User/Group details
924 **********************************************************/
927 * @brief Fill in a struct passwd* for a domain user based
928 * on username
930 * @param *name Username to lookup
931 * @param **pwd Pointer to resulting struct passwd* from the query.
933 * @return #wbcErr
935 wbcErr wbcGetpwnam(const char *name, struct passwd **pwd);
938 * @brief Fill in a struct passwd* for a domain user based
939 * on uid
941 * @param uid Uid to lookup
942 * @param **pwd Pointer to resulting struct passwd* from the query.
944 * @return #wbcErr
946 wbcErr wbcGetpwuid(uid_t uid, struct passwd **pwd);
949 * @brief Fill in a struct passwd* for a domain user based
950 * on sid
952 * @param sid Sid to lookup
953 * @param **pwd Pointer to resulting struct passwd* from the query.
955 * @return #wbcErr
957 wbcErr wbcGetpwsid(struct wbcDomainSid * sid, struct passwd **pwd);
960 * @brief Fill in a struct passwd* for a domain user based
961 * on username
963 * @param *name Username to lookup
964 * @param **grp Pointer to resulting struct group* from the query.
966 * @return #wbcErr
968 wbcErr wbcGetgrnam(const char *name, struct group **grp);
971 * @brief Fill in a struct passwd* for a domain user based
972 * on uid
974 * @param gid Uid to lookup
975 * @param **grp Pointer to resulting struct group* from the query.
977 * @return #wbcErr
979 wbcErr wbcGetgrgid(gid_t gid, struct group **grp);
982 * @brief Reset the passwd iterator
984 * @return #wbcErr
986 wbcErr wbcSetpwent(void);
989 * @brief Close the passwd iterator
991 * @return #wbcErr
993 wbcErr wbcEndpwent(void);
996 * @brief Return the next struct passwd* entry from the pwent iterator
998 * @param **pwd Pointer to resulting struct passwd* from the query.
1000 * @return #wbcErr
1002 wbcErr wbcGetpwent(struct passwd **pwd);
1005 * @brief Reset the group iterator
1007 * @return #wbcErr
1009 wbcErr wbcSetgrent(void);
1012 * @brief Close the group iterator
1014 * @return #wbcErr
1016 wbcErr wbcEndgrent(void);
1019 * @brief Return the next struct group* entry from the pwent iterator
1021 * @param **grp Pointer to resulting struct group* from the query.
1023 * @return #wbcErr
1025 wbcErr wbcGetgrent(struct group **grp);
1028 * @brief Return the next struct group* entry from the pwent iterator
1030 * This is similar to #wbcGetgrent, just that the member list is empty
1032 * @param **grp Pointer to resulting struct group* from the query.
1034 * @return #wbcErr
1036 wbcErr wbcGetgrlist(struct group **grp);
1039 * @brief Return the unix group array belonging to the given user
1041 * @param *account The given user name
1042 * @param *num_groups Number of elements returned in the groups array
1043 * @param **_groups Pointer to resulting gid_t array.
1045 * @return #wbcErr
1047 wbcErr wbcGetGroups(const char *account,
1048 uint32_t *num_groups,
1049 gid_t **_groups);
1052 /**********************************************************
1053 * Lookup Domain information
1054 **********************************************************/
1057 * @brief Lookup the current status of a trusted domain
1059 * @param domain The domain to query
1061 * @param dinfo A pointer to store the returned domain_info struct.
1063 * @return #wbcErr
1065 wbcErr wbcDomainInfo(const char *domain,
1066 struct wbcDomainInfo **dinfo);
1069 * @brief Lookup the currently contacted DCs
1071 * @param domain The domain to query
1073 * @param num_dcs Number of DCs currently known
1074 * @param dc_names Names of the currently known DCs
1075 * @param dc_ips IP addresses of the currently known DCs
1077 * @return #wbcErr
1079 wbcErr wbcDcInfo(const char *domain, size_t *num_dcs,
1080 const char ***dc_names, const char ***dc_ips);
1083 * @brief Enumerate the domain trusts known by Winbind
1085 * @param **domains Pointer to the allocated domain list array
1086 * @param *num_domains Pointer to number of domains returned
1088 * @return #wbcErr
1090 wbcErr wbcListTrusts(struct wbcDomainInfo **domains,
1091 size_t *num_domains);
1093 /* Flags for wbcLookupDomainController */
1095 #define WBC_LOOKUP_DC_FORCE_REDISCOVERY 0x00000001
1096 #define WBC_LOOKUP_DC_DS_REQUIRED 0x00000010
1097 #define WBC_LOOKUP_DC_DS_PREFERRED 0x00000020
1098 #define WBC_LOOKUP_DC_GC_SERVER_REQUIRED 0x00000040
1099 #define WBC_LOOKUP_DC_PDC_REQUIRED 0x00000080
1100 #define WBC_LOOKUP_DC_BACKGROUND_ONLY 0x00000100
1101 #define WBC_LOOKUP_DC_IP_REQUIRED 0x00000200
1102 #define WBC_LOOKUP_DC_KDC_REQUIRED 0x00000400
1103 #define WBC_LOOKUP_DC_TIMESERV_REQUIRED 0x00000800
1104 #define WBC_LOOKUP_DC_WRITABLE_REQUIRED 0x00001000
1105 #define WBC_LOOKUP_DC_GOOD_TIMESERV_PREFERRED 0x00002000
1106 #define WBC_LOOKUP_DC_AVOID_SELF 0x00004000
1107 #define WBC_LOOKUP_DC_ONLY_LDAP_NEEDED 0x00008000
1108 #define WBC_LOOKUP_DC_IS_FLAT_NAME 0x00010000
1109 #define WBC_LOOKUP_DC_IS_DNS_NAME 0x00020000
1110 #define WBC_LOOKUP_DC_TRY_NEXTCLOSEST_SITE 0x00040000
1111 #define WBC_LOOKUP_DC_DS_6_REQUIRED 0x00080000
1112 #define WBC_LOOKUP_DC_RETURN_DNS_NAME 0x40000000
1113 #define WBC_LOOKUP_DC_RETURN_FLAT_NAME 0x80000000
1116 * @brief Enumerate the domain trusts known by Winbind
1118 * @param domain Name of the domain to query for a DC
1119 * @param flags Bit flags used to control the domain location query
1120 * @param *dc_info Pointer to the returned domain controller information
1122 * @return #wbcErr
1124 wbcErr wbcLookupDomainController(const char *domain,
1125 uint32_t flags,
1126 struct wbcDomainControllerInfo **dc_info);
1129 * @brief Get extended domain controller information
1131 * @param domain Name of the domain to query for a DC
1132 * @param guid Guid of the domain to query for a DC
1133 * @param site Site of the domain to query for a DC
1134 * @param flags Bit flags used to control the domain location query
1135 * @param *dc_info Pointer to the returned extended domain controller information
1137 * @return #wbcErr
1139 wbcErr wbcLookupDomainControllerEx(const char *domain,
1140 struct wbcGuid *guid,
1141 const char *site,
1142 uint32_t flags,
1143 struct wbcDomainControllerInfoEx **dc_info);
1145 /**********************************************************
1146 * Athenticate functions
1147 **********************************************************/
1150 * @brief Authenticate a username/password pair
1152 * @param username Name of user to authenticate
1153 * @param password Clear text password os user
1155 * @return #wbcErr
1157 wbcErr wbcAuthenticateUser(const char *username,
1158 const char *password);
1161 * @brief Authenticate with more detailed information
1163 * @param params Input parameters, WBC_AUTH_USER_LEVEL_HASH
1164 * is not supported yet
1165 * @param info Output details on WBC_ERR_SUCCESS
1166 * @param error Output details on WBC_ERR_AUTH_ERROR
1168 * @return #wbcErr
1170 wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params,
1171 struct wbcAuthUserInfo **info,
1172 struct wbcAuthErrorInfo **error);
1175 * @brief Logon a User
1177 * @param[in] params Pointer to a wbcLogonUserParams structure
1178 * @param[out] info Pointer to a pointer to a wbcLogonUserInfo structure
1179 * @param[out] error Pointer to a pointer to a wbcAuthErrorInfo structure
1180 * @param[out] policy Pointer to a pointer to a wbcUserPasswordPolicyInfo structure
1182 * @return #wbcErr
1184 wbcErr wbcLogonUser(const struct wbcLogonUserParams *params,
1185 struct wbcLogonUserInfo **info,
1186 struct wbcAuthErrorInfo **error,
1187 struct wbcUserPasswordPolicyInfo **policy);
1190 * @brief Trigger a logoff notification to Winbind for a specific user
1192 * @param username Name of user to remove from Winbind's list of
1193 * logged on users.
1194 * @param uid Uid assigned to the username
1195 * @param ccfilename Absolute path to the Krb5 credentials cache to
1196 * be removed
1198 * @return #wbcErr
1200 wbcErr wbcLogoffUser(const char *username,
1201 uid_t uid,
1202 const char *ccfilename);
1205 * @brief Trigger an extended logoff notification to Winbind for a specific user
1207 * @param params A wbcLogoffUserParams structure
1208 * @param error User output details on error
1210 * @return #wbcErr
1212 wbcErr wbcLogoffUserEx(const struct wbcLogoffUserParams *params,
1213 struct wbcAuthErrorInfo **error);
1216 * @brief Change a password for a user
1218 * @param username Name of user to authenticate
1219 * @param old_password Old clear text password of user
1220 * @param new_password New clear text password of user
1222 * @return #wbcErr
1224 wbcErr wbcChangeUserPassword(const char *username,
1225 const char *old_password,
1226 const char *new_password);
1229 * @brief Change a password for a user with more detailed information upon
1230 * failure
1232 * @param params Input parameters
1233 * @param error User output details on WBC_ERR_PWD_CHANGE_FAILED
1234 * @param reject_reason New password reject reason on WBC_ERR_PWD_CHANGE_FAILED
1235 * @param policy Password policy output details on WBC_ERR_PWD_CHANGE_FAILED
1237 * @return #wbcErr
1239 wbcErr wbcChangeUserPasswordEx(const struct wbcChangePasswordParams *params,
1240 struct wbcAuthErrorInfo **error,
1241 enum wbcPasswordChangeRejectReason *reject_reason,
1242 struct wbcUserPasswordPolicyInfo **policy);
1245 * @brief Authenticate a user with cached credentials
1247 * @param *params Pointer to a wbcCredentialCacheParams structure
1248 * @param **info Pointer to a pointer to a wbcCredentialCacheInfo structure
1249 * @param **error Pointer to a pointer to a wbcAuthErrorInfo structure
1251 * @return #wbcErr
1253 wbcErr wbcCredentialCache(struct wbcCredentialCacheParams *params,
1254 struct wbcCredentialCacheInfo **info,
1255 struct wbcAuthErrorInfo **error);
1258 * @brief Save a password with winbind for doing wbcCredentialCache() later
1260 * @param *user Username
1261 * @param *password Password
1263 * @return #wbcErr
1265 wbcErr wbcCredentialSave(const char *user, const char *password);
1267 /**********************************************************
1268 * Resolve functions
1269 **********************************************************/
1272 * @brief Resolve a NetbiosName via WINS
1274 * @param name Name to resolve
1275 * @param *ip Pointer to the ip address string
1277 * @return #wbcErr
1279 wbcErr wbcResolveWinsByName(const char *name, char **ip);
1282 * @brief Resolve an IP address via WINS into a NetbiosName
1284 * @param ip The ip address string
1285 * @param *name Pointer to the name
1287 * @return #wbcErr
1290 wbcErr wbcResolveWinsByIP(const char *ip, char **name);
1292 /**********************************************************
1293 * Trusted domain functions
1294 **********************************************************/
1297 * @brief Trigger a verification of the trust credentials of a specific domain
1299 * @param *domain The name of the domain.
1300 * @param error Output details on WBC_ERR_AUTH_ERROR
1302 * @return #wbcErr
1304 wbcErr wbcCheckTrustCredentials(const char *domain,
1305 struct wbcAuthErrorInfo **error);
1308 * @brief Trigger a change of the trust credentials for a specific domain
1310 * @param *domain The name of the domain.
1311 * @param error Output details on WBC_ERR_AUTH_ERROR
1313 * @return #wbcErr
1315 wbcErr wbcChangeTrustCredentials(const char *domain,
1316 struct wbcAuthErrorInfo **error);
1319 * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost
1320 * version of wbcCheckTrustCredentials
1322 * @param *domain The name of the domain, only NULL for the default domain is
1323 * supported yet. Other values than NULL will result in
1324 * WBC_ERR_NOT_IMPLEMENTED.
1325 * @param error Output details on WBC_ERR_AUTH_ERROR
1327 * @return #wbcErr
1329 wbcErr wbcPingDc(const char *domain, struct wbcAuthErrorInfo **error);
1332 * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost
1333 * version of wbcCheckTrustCredentials
1335 * @param *domain The name of the domain, only NULL for the default domain is
1336 * supported yet. Other values than NULL will result in
1337 * WBC_ERR_NOT_IMPLEMENTED.
1338 * @param error Output details on WBC_ERR_AUTH_ERROR
1339 * @param dcname DC that was attempted to ping
1341 * @return #wbcErr
1343 wbcErr wbcPingDc2(const char *domain, struct wbcAuthErrorInfo **error,
1344 char **dcname);
1346 /**********************************************************
1347 * Helper functions
1348 **********************************************************/
1351 * @brief Initialize a named blob and add to list of blobs
1353 * @param[in,out] num_blobs Pointer to the number of blobs
1354 * @param[in,out] blobs Pointer to an array of blobs
1355 * @param[in] name Name of the new named blob
1356 * @param[in] flags Flags of the new named blob
1357 * @param[in] data Blob data of new blob
1358 * @param[in] length Blob data length of new blob
1360 * @return #wbcErr
1362 wbcErr wbcAddNamedBlob(size_t *num_blobs,
1363 struct wbcNamedBlob **blobs,
1364 const char *name,
1365 uint32_t flags,
1366 uint8_t *data,
1367 size_t length);
1369 #endif /* _WBCLIENT_H */