s4:libcli/raw: remove unused SMB_SIGNING_AUTO handling
[Samba/gebeck_regimport.git] / nsswitch / libwbclient / wbclient.h
blob809e00a0076cdbe0e38248721d2854d53143aaa1
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 **/
72 #define WBCLIENT_MAJOR_VERSION 0
73 #define WBCLIENT_MINOR_VERSION 8
74 #define WBCLIENT_VENDOR_VERSION "Samba libwbclient"
75 struct wbcLibraryDetails {
76 uint16_t major_version;
77 uint16_t minor_version;
78 const char *vendor_version;
81 /**
82 * @brief Some useful details about the running winbindd
84 **/
85 struct wbcInterfaceDetails {
86 uint32_t interface_version;
87 char *winbind_version;
88 char winbind_separator;
89 char *netbios_name;
90 char *netbios_domain;
91 char *dns_domain;
95 * Data types used by the Winbind Client API
98 #ifndef WBC_MAXSUBAUTHS
99 #define WBC_MAXSUBAUTHS 15 /* max sub authorities in a SID */
100 #endif
103 * @brief Windows Security Identifier
107 struct wbcDomainSid {
108 uint8_t sid_rev_num;
109 uint8_t num_auths;
110 uint8_t id_auth[6];
111 uint32_t sub_auths[WBC_MAXSUBAUTHS];
115 * @brief Security Identifier type
118 enum wbcSidType {
119 WBC_SID_NAME_USE_NONE=0,
120 WBC_SID_NAME_USER=1,
121 WBC_SID_NAME_DOM_GRP=2,
122 WBC_SID_NAME_DOMAIN=3,
123 WBC_SID_NAME_ALIAS=4,
124 WBC_SID_NAME_WKN_GRP=5,
125 WBC_SID_NAME_DELETED=6,
126 WBC_SID_NAME_INVALID=7,
127 WBC_SID_NAME_UNKNOWN=8,
128 WBC_SID_NAME_COMPUTER=9
132 * @brief Security Identifier with attributes
135 struct wbcSidWithAttr {
136 struct wbcDomainSid sid;
137 uint32_t attributes;
140 /* wbcSidWithAttr->attributes */
142 #define WBC_SID_ATTR_GROUP_MANDATORY 0x00000001
143 #define WBC_SID_ATTR_GROUP_ENABLED_BY_DEFAULT 0x00000002
144 #define WBC_SID_ATTR_GROUP_ENABLED 0x00000004
145 #define WBC_SID_ATTR_GROUP_OWNER 0x00000008
146 #define WBC_SID_ATTR_GROUP_USEFOR_DENY_ONLY 0x00000010
147 #define WBC_SID_ATTR_GROUP_RESOURCE 0x20000000
148 #define WBC_SID_ATTR_GROUP_LOGON_ID 0xC0000000
151 * @brief Windows GUID
155 struct wbcGuid {
156 uint32_t time_low;
157 uint16_t time_mid;
158 uint16_t time_hi_and_version;
159 uint8_t clock_seq[2];
160 uint8_t node[6];
164 * @brief Domain Information
167 struct wbcDomainInfo {
168 char *short_name;
169 char *dns_name;
170 struct wbcDomainSid sid;
171 uint32_t domain_flags;
172 uint32_t trust_flags;
173 uint32_t trust_type;
176 /* wbcDomainInfo->domain_flags */
178 #define WBC_DOMINFO_DOMAIN_UNKNOWN 0x00000000
179 #define WBC_DOMINFO_DOMAIN_NATIVE 0x00000001
180 #define WBC_DOMINFO_DOMAIN_AD 0x00000002
181 #define WBC_DOMINFO_DOMAIN_PRIMARY 0x00000004
182 #define WBC_DOMINFO_DOMAIN_OFFLINE 0x00000008
184 /* wbcDomainInfo->trust_flags */
186 #define WBC_DOMINFO_TRUST_TRANSITIVE 0x00000001
187 #define WBC_DOMINFO_TRUST_INCOMING 0x00000002
188 #define WBC_DOMINFO_TRUST_OUTGOING 0x00000004
190 /* wbcDomainInfo->trust_type */
192 #define WBC_DOMINFO_TRUSTTYPE_NONE 0x00000000
193 #define WBC_DOMINFO_TRUSTTYPE_FOREST 0x00000001
194 #define WBC_DOMINFO_TRUSTTYPE_IN_FOREST 0x00000002
195 #define WBC_DOMINFO_TRUSTTYPE_EXTERNAL 0x00000003
198 * @brief Auth User Parameters
201 struct wbcAuthUserParams {
202 const char *account_name;
203 const char *domain_name;
204 const char *workstation_name;
206 uint32_t flags;
208 uint32_t parameter_control;
210 enum wbcAuthUserLevel {
211 WBC_AUTH_USER_LEVEL_PLAIN = 1,
212 WBC_AUTH_USER_LEVEL_HASH = 2,
213 WBC_AUTH_USER_LEVEL_RESPONSE = 3
214 } level;
215 union {
216 const char *plaintext;
217 struct {
218 uint8_t nt_hash[16];
219 uint8_t lm_hash[16];
220 } hash;
221 struct {
222 uint8_t challenge[8];
223 uint32_t nt_length;
224 uint8_t *nt_data;
225 uint32_t lm_length;
226 uint8_t *lm_data;
227 } response;
228 } password;
232 * @brief Generic Blob
235 struct wbcBlob {
236 uint8_t *data;
237 size_t length;
241 * @brief Named Blob
244 struct wbcNamedBlob {
245 const char *name;
246 uint32_t flags;
247 struct wbcBlob blob;
251 * @brief Logon User Parameters
254 struct wbcLogonUserParams {
255 const char *username;
256 const char *password;
257 size_t num_blobs;
258 struct wbcNamedBlob *blobs;
262 * @brief ChangePassword Parameters
265 struct wbcChangePasswordParams {
266 const char *account_name;
267 const char *domain_name;
269 uint32_t flags;
271 enum wbcChangePasswordLevel {
272 WBC_CHANGE_PASSWORD_LEVEL_PLAIN = 1,
273 WBC_CHANGE_PASSWORD_LEVEL_RESPONSE = 2
274 } level;
276 union {
277 const char *plaintext;
278 struct {
279 uint32_t old_nt_hash_enc_length;
280 uint8_t *old_nt_hash_enc_data;
281 uint32_t old_lm_hash_enc_length;
282 uint8_t *old_lm_hash_enc_data;
283 } response;
284 } old_password;
285 union {
286 const char *plaintext;
287 struct {
288 uint32_t nt_length;
289 uint8_t *nt_data;
290 uint32_t lm_length;
291 uint8_t *lm_data;
292 } response;
293 } new_password;
296 /* wbcAuthUserParams->parameter_control */
298 #define WBC_MSV1_0_CLEARTEXT_PASSWORD_ALLOWED 0x00000002
299 #define WBC_MSV1_0_UPDATE_LOGON_STATISTICS 0x00000004
300 #define WBC_MSV1_0_RETURN_USER_PARAMETERS 0x00000008
301 #define WBC_MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT 0x00000020
302 #define WBC_MSV1_0_RETURN_PROFILE_PATH 0x00000200
303 #define WBC_MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT 0x00000800
305 /* wbcAuthUserParams->flags */
307 #define WBC_AUTH_PARAM_FLAGS_INTERACTIVE_LOGON 0x00000001
310 * @brief Auth User Information
312 * Some of the strings are maybe NULL
315 struct wbcAuthUserInfo {
316 uint32_t user_flags;
318 char *account_name;
319 char *user_principal;
320 char *full_name;
321 char *domain_name;
322 char *dns_domain_name;
324 uint32_t acct_flags;
325 uint8_t user_session_key[16];
326 uint8_t lm_session_key[8];
328 uint16_t logon_count;
329 uint16_t bad_password_count;
331 uint64_t logon_time;
332 uint64_t logoff_time;
333 uint64_t kickoff_time;
334 uint64_t pass_last_set_time;
335 uint64_t pass_can_change_time;
336 uint64_t pass_must_change_time;
338 char *logon_server;
339 char *logon_script;
340 char *profile_path;
341 char *home_directory;
342 char *home_drive;
345 * the 1st one is the account sid
346 * the 2nd one is the primary_group sid
347 * followed by the rest of the groups
349 uint32_t num_sids;
350 struct wbcSidWithAttr *sids;
354 * @brief Logon User Information
356 * Some of the strings are maybe NULL
359 struct wbcLogonUserInfo {
360 struct wbcAuthUserInfo *info;
361 size_t num_blobs;
362 struct wbcNamedBlob *blobs;
365 /* wbcAuthUserInfo->user_flags */
367 #define WBC_AUTH_USER_INFO_GUEST 0x00000001
368 #define WBC_AUTH_USER_INFO_NOENCRYPTION 0x00000002
369 #define WBC_AUTH_USER_INFO_CACHED_ACCOUNT 0x00000004
370 #define WBC_AUTH_USER_INFO_USED_LM_PASSWORD 0x00000008
371 #define WBC_AUTH_USER_INFO_EXTRA_SIDS 0x00000020
372 #define WBC_AUTH_USER_INFO_SUBAUTH_SESSION_KEY 0x00000040
373 #define WBC_AUTH_USER_INFO_SERVER_TRUST_ACCOUNT 0x00000080
374 #define WBC_AUTH_USER_INFO_NTLMV2_ENABLED 0x00000100
375 #define WBC_AUTH_USER_INFO_RESOURCE_GROUPS 0x00000200
376 #define WBC_AUTH_USER_INFO_PROFILE_PATH_RETURNED 0x00000400
377 #define WBC_AUTH_USER_INFO_GRACE_LOGON 0x01000000
379 /* wbcAuthUserInfo->acct_flags */
381 #define WBC_ACB_DISABLED 0x00000001 /* 1 User account disabled */
382 #define WBC_ACB_HOMDIRREQ 0x00000002 /* 1 Home directory required */
383 #define WBC_ACB_PWNOTREQ 0x00000004 /* 1 User password not required */
384 #define WBC_ACB_TEMPDUP 0x00000008 /* 1 Temporary duplicate account */
385 #define WBC_ACB_NORMAL 0x00000010 /* 1 Normal user account */
386 #define WBC_ACB_MNS 0x00000020 /* 1 MNS logon user account */
387 #define WBC_ACB_DOMTRUST 0x00000040 /* 1 Interdomain trust account */
388 #define WBC_ACB_WSTRUST 0x00000080 /* 1 Workstation trust account */
389 #define WBC_ACB_SVRTRUST 0x00000100 /* 1 Server trust account */
390 #define WBC_ACB_PWNOEXP 0x00000200 /* 1 User password does not expire */
391 #define WBC_ACB_AUTOLOCK 0x00000400 /* 1 Account auto locked */
392 #define WBC_ACB_ENC_TXT_PWD_ALLOWED 0x00000800 /* 1 Encryped text password is allowed */
393 #define WBC_ACB_SMARTCARD_REQUIRED 0x00001000 /* 1 Smart Card required */
394 #define WBC_ACB_TRUSTED_FOR_DELEGATION 0x00002000 /* 1 Trusted for Delegation */
395 #define WBC_ACB_NOT_DELEGATED 0x00004000 /* 1 Not delegated */
396 #define WBC_ACB_USE_DES_KEY_ONLY 0x00008000 /* 1 Use DES key only */
397 #define WBC_ACB_DONT_REQUIRE_PREAUTH 0x00010000 /* 1 Preauth not required */
398 #define WBC_ACB_PW_EXPIRED 0x00020000 /* 1 Password Expired */
399 #define WBC_ACB_NO_AUTH_DATA_REQD 0x00080000 /* 1 = No authorization data required */
401 struct wbcAuthErrorInfo {
402 uint32_t nt_status;
403 char *nt_string;
404 int32_t pam_error;
405 char *display_string;
409 * @brief User Password Policy Information
412 /* wbcUserPasswordPolicyInfo->password_properties */
414 #define WBC_DOMAIN_PASSWORD_COMPLEX 0x00000001
415 #define WBC_DOMAIN_PASSWORD_NO_ANON_CHANGE 0x00000002
416 #define WBC_DOMAIN_PASSWORD_NO_CLEAR_CHANGE 0x00000004
417 #define WBC_DOMAIN_PASSWORD_LOCKOUT_ADMINS 0x00000008
418 #define WBC_DOMAIN_PASSWORD_STORE_CLEARTEXT 0x00000010
419 #define WBC_DOMAIN_REFUSE_PASSWORD_CHANGE 0x00000020
421 struct wbcUserPasswordPolicyInfo {
422 uint32_t min_length_password;
423 uint32_t password_history;
424 uint32_t password_properties;
425 uint64_t expire;
426 uint64_t min_passwordage;
430 * @brief Change Password Reject Reason
433 enum wbcPasswordChangeRejectReason {
434 WBC_PWD_CHANGE_NO_ERROR=0,
435 WBC_PWD_CHANGE_PASSWORD_TOO_SHORT=1,
436 WBC_PWD_CHANGE_PWD_IN_HISTORY=2,
437 WBC_PWD_CHANGE_USERNAME_IN_PASSWORD=3,
438 WBC_PWD_CHANGE_FULLNAME_IN_PASSWORD=4,
439 WBC_PWD_CHANGE_NOT_COMPLEX=5,
440 WBC_PWD_CHANGE_MACHINE_NOT_DEFAULT=6,
441 WBC_PWD_CHANGE_FAILED_BY_FILTER=7,
442 WBC_PWD_CHANGE_PASSWORD_TOO_LONG=8
445 /* Note: this defines exist for compatibility reasons with existing code */
446 #define WBC_PWD_CHANGE_REJECT_OTHER WBC_PWD_CHANGE_NO_ERROR
447 #define WBC_PWD_CHANGE_REJECT_TOO_SHORT WBC_PWD_CHANGE_PASSWORD_TOO_SHORT
448 #define WBC_PWD_CHANGE_REJECT_IN_HISTORY WBC_PWD_CHANGE_PWD_IN_HISTORY
449 #define WBC_PWD_CHANGE_REJECT_COMPLEXITY WBC_PWD_CHANGE_NOT_COMPLEX
452 * @brief Logoff User Parameters
455 struct wbcLogoffUserParams {
456 const char *username;
457 size_t num_blobs;
458 struct wbcNamedBlob *blobs;
461 /** @brief Credential cache log-on parameters
465 struct wbcCredentialCacheParams {
466 const char *account_name;
467 const char *domain_name;
468 enum wbcCredentialCacheLevel {
469 WBC_CREDENTIAL_CACHE_LEVEL_NTLMSSP = 1
470 } level;
471 size_t num_blobs;
472 struct wbcNamedBlob *blobs;
476 /** @brief Info returned by credential cache auth
480 struct wbcCredentialCacheInfo {
481 size_t num_blobs;
482 struct wbcNamedBlob *blobs;
486 * DomainControllerInfo struct
488 struct wbcDomainControllerInfo {
489 char *dc_name;
493 * DomainControllerInfoEx struct
495 struct wbcDomainControllerInfoEx {
496 const char *dc_unc;
497 const char *dc_address;
498 uint16_t dc_address_type;
499 struct wbcGuid *domain_guid;
500 const char *domain_name;
501 const char *forest_name;
502 uint32_t dc_flags;
503 const char *dc_site_name;
504 const char *client_site_name;
507 /**********************************************************
508 * Memory Management
509 **********************************************************/
512 * @brief Free library allocated memory
514 * @param * Pointer to free
516 * @return void
518 void wbcFreeMemory(void*);
522 * Utility functions for dealing with SIDs
526 * @brief Get a string representation of the SID type
528 * @param type type of the SID
530 * @return string representation of the SID type
532 const char* wbcSidTypeString(enum wbcSidType type);
534 #define WBC_SID_STRING_BUFLEN (15*11+25)
537 * @brief Print a sid into a buffer
539 * @param sid Binary Security Identifier
540 * @param buf Target buffer
541 * @param buflen Target buffer length
543 * @return Resulting string length.
545 int wbcSidToStringBuf(const struct wbcDomainSid *sid, char *buf, int buflen);
548 * @brief Convert a binary SID to a character string
550 * @param sid Binary Security Identifier
551 * @param **sid_string Resulting character string
553 * @return #wbcErr
555 wbcErr wbcSidToString(const struct wbcDomainSid *sid,
556 char **sid_string);
559 * @brief Convert a character string to a binary SID
561 * @param *sid_string Character string in the form of S-...
562 * @param sid Resulting binary SID
564 * @return #wbcErr
566 wbcErr wbcStringToSid(const char *sid_string,
567 struct wbcDomainSid *sid);
570 * Utility functions for dealing with GUIDs
574 * @brief Convert a binary GUID to a character string
576 * @param guid Binary Guid
577 * @param **guid_string Resulting character string
579 * @return #wbcErr
581 wbcErr wbcGuidToString(const struct wbcGuid *guid,
582 char **guid_string);
585 * @brief Convert a character string to a binary GUID
587 * @param *guid_string Character string
588 * @param guid Resulting binary GUID
590 * @return #wbcErr
592 wbcErr wbcStringToGuid(const char *guid_string,
593 struct wbcGuid *guid);
596 * @brief Ping winbindd to see if the daemon is running
598 * @return #wbcErr
600 wbcErr wbcPing(void);
602 wbcErr wbcLibraryDetails(struct wbcLibraryDetails **details);
604 wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **details);
606 /**********************************************************
607 * Name/SID conversion
608 **********************************************************/
611 * @brief Convert a domain and name to SID
613 * @param dom_name Domain name (possibly "")
614 * @param name User or group name
615 * @param *sid Pointer to the resolved domain SID
616 * @param *name_type Pointer to the SID type
618 * @return #wbcErr
620 wbcErr wbcLookupName(const char *dom_name,
621 const char *name,
622 struct wbcDomainSid *sid,
623 enum wbcSidType *name_type);
626 * @brief Convert a SID to a domain and name
628 * @param *sid Pointer to the domain SID to be resolved
629 * @param domain Resolved Domain name (possibly "")
630 * @param name Resolved User or group name
631 * @param *name_type Pointer to the resolved SID type
633 * @return #wbcErr
635 wbcErr wbcLookupSid(const struct wbcDomainSid *sid,
636 char **domain,
637 char **name,
638 enum wbcSidType *name_type);
640 struct wbcTranslatedName {
641 enum wbcSidType type;
642 char *name;
643 int domain_index;
646 wbcErr wbcLookupSids(const struct wbcDomainSid *sids, int num_sids,
647 struct wbcDomainInfo **domains, int *num_domains,
648 struct wbcTranslatedName **names);
651 * @brief Translate a collection of RIDs within a domain to names
653 wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
654 int num_rids,
655 uint32_t *rids,
656 const char **domain_name,
657 const char ***names,
658 enum wbcSidType **types);
661 * @brief Get the groups a user belongs to
663 wbcErr wbcLookupUserSids(const struct wbcDomainSid *user_sid,
664 bool domain_groups_only,
665 uint32_t *num_sids,
666 struct wbcDomainSid **sids);
669 * @brief Get alias membership for sids
671 wbcErr wbcGetSidAliases(const struct wbcDomainSid *dom_sid,
672 struct wbcDomainSid *sids,
673 uint32_t num_sids,
674 uint32_t **alias_rids,
675 uint32_t *num_alias_rids);
678 * @brief Lists Users
680 wbcErr wbcListUsers(const char *domain_name,
681 uint32_t *num_users,
682 const char ***users);
685 * @brief Lists Groups
687 wbcErr wbcListGroups(const char *domain_name,
688 uint32_t *num_groups,
689 const char ***groups);
691 wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid,
692 char **pdomain,
693 char **pfullname,
694 enum wbcSidType *pname_type);
696 /**********************************************************
697 * SID/uid/gid Mappings
698 **********************************************************/
701 * @brief Convert a Windows SID to a Unix uid, allocating an uid if needed
703 * @param *sid Pointer to the domain SID to be resolved
704 * @param *puid Pointer to the resolved uid_t value
706 * @return #wbcErr
709 wbcErr wbcSidToUid(const struct wbcDomainSid *sid,
710 uid_t *puid);
713 * @brief Convert a Windows SID to a Unix uid if there already is a mapping
715 * @param *sid Pointer to the domain SID to be resolved
716 * @param *puid Pointer to the resolved uid_t value
718 * @return #wbcErr
721 wbcErr wbcQuerySidToUid(const struct wbcDomainSid *sid,
722 uid_t *puid);
725 * @brief Convert a Unix uid to a Windows SID, allocating a SID if needed
727 * @param uid Unix uid to be resolved
728 * @param *sid Pointer to the resolved domain SID
730 * @return #wbcErr
733 wbcErr wbcUidToSid(uid_t uid,
734 struct wbcDomainSid *sid);
737 * @brief Convert a Unix uid to a Windows SID if there already is a mapping
739 * @param uid Unix uid to be resolved
740 * @param *sid Pointer to the resolved domain SID
742 * @return #wbcErr
745 wbcErr wbcQueryUidToSid(uid_t uid,
746 struct wbcDomainSid *sid);
749 * @brief Convert a Windows SID to a Unix gid, allocating a gid if needed
751 * @param *sid Pointer to the domain SID to be resolved
752 * @param *pgid Pointer to the resolved gid_t value
754 * @return #wbcErr
757 wbcErr wbcSidToGid(const struct wbcDomainSid *sid,
758 gid_t *pgid);
761 * @brief Convert a Windows SID to a Unix gid if there already is a mapping
763 * @param *sid Pointer to the domain SID to be resolved
764 * @param *pgid Pointer to the resolved gid_t value
766 * @return #wbcErr
769 wbcErr wbcQuerySidToGid(const struct wbcDomainSid *sid,
770 gid_t *pgid);
773 * @brief Convert a Unix gid to a Windows SID, allocating a SID if needed
775 * @param gid Unix gid to be resolved
776 * @param *sid Pointer to the resolved domain SID
778 * @return #wbcErr
781 wbcErr wbcGidToSid(gid_t gid,
782 struct wbcDomainSid *sid);
785 * @brief Convert a Unix gid to a Windows SID if there already is a mapping
787 * @param gid Unix gid to be resolved
788 * @param *sid Pointer to the resolved domain SID
790 * @return #wbcErr
793 wbcErr wbcQueryGidToSid(gid_t gid,
794 struct wbcDomainSid *sid);
796 enum wbcIdType {
797 WBC_ID_TYPE_NOT_SPECIFIED,
798 WBC_ID_TYPE_UID,
799 WBC_ID_TYPE_GID,
800 WBC_ID_TYPE_BOTH
803 union wbcUnixIdContainer {
804 uid_t uid;
805 gid_t gid;
808 struct wbcUnixId {
809 enum wbcIdType type;
810 union wbcUnixIdContainer id;
814 * @brief Convert a list of sids to unix ids
816 * @param sids Pointer to an array of SIDs to convert
817 * @param num_sids Number of SIDs
818 * @param ids Preallocated output array for translated IDs
820 * @return #wbcErr
823 wbcErr wbcSidsToUnixIds(const struct wbcDomainSid *sids, uint32_t num_sids,
824 struct wbcUnixId *ids);
827 * @brief Obtain a new uid from Winbind
829 * @param *puid *pointer to the allocated uid
831 * @return #wbcErr
833 wbcErr wbcAllocateUid(uid_t *puid);
836 * @brief Obtain a new gid from Winbind
838 * @param *pgid Pointer to the allocated gid
840 * @return #wbcErr
842 wbcErr wbcAllocateGid(gid_t *pgid);
845 * @brief Set an user id mapping
847 * @param uid Uid of the desired mapping.
848 * @param *sid Pointer to the sid of the diresired mapping.
850 * @return #wbcErr
852 * @deprecated This method is not impemented any more and should
853 * be removed in the next major version change.
855 wbcErr wbcSetUidMapping(uid_t uid, const struct wbcDomainSid *sid);
858 * @brief Set a group id mapping
860 * @param gid Gid of the desired mapping.
861 * @param *sid Pointer to the sid of the diresired mapping.
863 * @return #wbcErr
865 * @deprecated This method is not impemented any more and should
866 * be removed in the next major version change.
868 wbcErr wbcSetGidMapping(gid_t gid, const struct wbcDomainSid *sid);
871 * @brief Remove a user id mapping
873 * @param uid Uid of the mapping to remove.
874 * @param *sid Pointer to the sid of the mapping to remove.
876 * @return #wbcErr
878 * @deprecated This method is not impemented any more and should
879 * be removed in the next major version change.
881 wbcErr wbcRemoveUidMapping(uid_t uid, const struct wbcDomainSid *sid);
884 * @brief Remove a group id mapping
886 * @param gid Gid of the mapping to remove.
887 * @param *sid Pointer to the sid of the mapping to remove.
889 * @return #wbcErr
891 * @deprecated This method is not impemented any more and should
892 * be removed in the next major version change.
894 wbcErr wbcRemoveGidMapping(gid_t gid, const struct wbcDomainSid *sid);
897 * @brief Set the highwater mark for allocated uids.
899 * @param uid_hwm The new uid highwater mark value
901 * @return #wbcErr
903 * @deprecated This method is not impemented any more and should
904 * be removed in the next major version change.
906 wbcErr wbcSetUidHwm(uid_t uid_hwm);
909 * @brief Set the highwater mark for allocated gids.
911 * @param gid_hwm The new gid highwater mark value
913 * @return #wbcErr
915 * @deprecated This method is not impemented any more and should
916 * be removed in the next major version change.
918 wbcErr wbcSetGidHwm(gid_t gid_hwm);
920 /**********************************************************
921 * NSS Lookup User/Group details
922 **********************************************************/
925 * @brief Fill in a struct passwd* for a domain user based
926 * on username
928 * @param *name Username to lookup
929 * @param **pwd Pointer to resulting struct passwd* from the query.
931 * @return #wbcErr
933 wbcErr wbcGetpwnam(const char *name, struct passwd **pwd);
936 * @brief Fill in a struct passwd* for a domain user based
937 * on uid
939 * @param uid Uid to lookup
940 * @param **pwd Pointer to resulting struct passwd* from the query.
942 * @return #wbcErr
944 wbcErr wbcGetpwuid(uid_t uid, struct passwd **pwd);
947 * @brief Fill in a struct passwd* for a domain user based
948 * on sid
950 * @param sid Sid to lookup
951 * @param **pwd Pointer to resulting struct passwd* from the query.
953 * @return #wbcErr
955 wbcErr wbcGetpwsid(struct wbcDomainSid * sid, struct passwd **pwd);
958 * @brief Fill in a struct passwd* for a domain user based
959 * on username
961 * @param *name Username to lookup
962 * @param **grp Pointer to resulting struct group* from the query.
964 * @return #wbcErr
966 wbcErr wbcGetgrnam(const char *name, struct group **grp);
969 * @brief Fill in a struct passwd* for a domain user based
970 * on uid
972 * @param gid Uid to lookup
973 * @param **grp Pointer to resulting struct group* from the query.
975 * @return #wbcErr
977 wbcErr wbcGetgrgid(gid_t gid, struct group **grp);
980 * @brief Reset the passwd iterator
982 * @return #wbcErr
984 wbcErr wbcSetpwent(void);
987 * @brief Close the passwd iterator
989 * @return #wbcErr
991 wbcErr wbcEndpwent(void);
994 * @brief Return the next struct passwd* entry from the pwent iterator
996 * @param **pwd Pointer to resulting struct passwd* from the query.
998 * @return #wbcErr
1000 wbcErr wbcGetpwent(struct passwd **pwd);
1003 * @brief Reset the group iterator
1005 * @return #wbcErr
1007 wbcErr wbcSetgrent(void);
1010 * @brief Close the group iterator
1012 * @return #wbcErr
1014 wbcErr wbcEndgrent(void);
1017 * @brief Return the next struct group* entry from the pwent iterator
1019 * @param **grp Pointer to resulting struct group* from the query.
1021 * @return #wbcErr
1023 wbcErr wbcGetgrent(struct group **grp);
1026 * @brief Return the next struct group* entry from the pwent iterator
1028 * This is similar to #wbcGetgrent, just that the member list is empty
1030 * @param **grp Pointer to resulting struct group* from the query.
1032 * @return #wbcErr
1034 wbcErr wbcGetgrlist(struct group **grp);
1037 * @brief Return the unix group array belonging to the given user
1039 * @param *account The given user name
1040 * @param *num_groups Number of elements returned in the groups array
1041 * @param **_groups Pointer to resulting gid_t array.
1043 * @return #wbcErr
1045 wbcErr wbcGetGroups(const char *account,
1046 uint32_t *num_groups,
1047 gid_t **_groups);
1050 /**********************************************************
1051 * Lookup Domain information
1052 **********************************************************/
1055 * @brief Lookup the current status of a trusted domain
1057 * @param domain The domain to query
1059 * @param dinfo A pointer to store the returned domain_info struct.
1061 * @return #wbcErr
1063 wbcErr wbcDomainInfo(const char *domain,
1064 struct wbcDomainInfo **dinfo);
1067 * @brief Lookup the currently contacted DCs
1069 * @param domain The domain to query
1071 * @param num_dcs Number of DCs currently known
1072 * @param dc_names Names of the currently known DCs
1073 * @param dc_ips IP addresses of the currently known DCs
1075 * @return #wbcErr
1077 wbcErr wbcDcInfo(const char *domain, size_t *num_dcs,
1078 const char ***dc_names, const char ***dc_ips);
1081 * @brief Enumerate the domain trusts known by Winbind
1083 * @param **domains Pointer to the allocated domain list array
1084 * @param *num_domains Pointer to number of domains returned
1086 * @return #wbcErr
1088 wbcErr wbcListTrusts(struct wbcDomainInfo **domains,
1089 size_t *num_domains);
1091 /* Flags for wbcLookupDomainController */
1093 #define WBC_LOOKUP_DC_FORCE_REDISCOVERY 0x00000001
1094 #define WBC_LOOKUP_DC_DS_REQUIRED 0x00000010
1095 #define WBC_LOOKUP_DC_DS_PREFERRED 0x00000020
1096 #define WBC_LOOKUP_DC_GC_SERVER_REQUIRED 0x00000040
1097 #define WBC_LOOKUP_DC_PDC_REQUIRED 0x00000080
1098 #define WBC_LOOKUP_DC_BACKGROUND_ONLY 0x00000100
1099 #define WBC_LOOKUP_DC_IP_REQUIRED 0x00000200
1100 #define WBC_LOOKUP_DC_KDC_REQUIRED 0x00000400
1101 #define WBC_LOOKUP_DC_TIMESERV_REQUIRED 0x00000800
1102 #define WBC_LOOKUP_DC_WRITABLE_REQUIRED 0x00001000
1103 #define WBC_LOOKUP_DC_GOOD_TIMESERV_PREFERRED 0x00002000
1104 #define WBC_LOOKUP_DC_AVOID_SELF 0x00004000
1105 #define WBC_LOOKUP_DC_ONLY_LDAP_NEEDED 0x00008000
1106 #define WBC_LOOKUP_DC_IS_FLAT_NAME 0x00010000
1107 #define WBC_LOOKUP_DC_IS_DNS_NAME 0x00020000
1108 #define WBC_LOOKUP_DC_TRY_NEXTCLOSEST_SITE 0x00040000
1109 #define WBC_LOOKUP_DC_DS_6_REQUIRED 0x00080000
1110 #define WBC_LOOKUP_DC_RETURN_DNS_NAME 0x40000000
1111 #define WBC_LOOKUP_DC_RETURN_FLAT_NAME 0x80000000
1114 * @brief Enumerate the domain trusts known by Winbind
1116 * @param domain Name of the domain to query for a DC
1117 * @param flags Bit flags used to control the domain location query
1118 * @param *dc_info Pointer to the returned domain controller information
1120 * @return #wbcErr
1122 wbcErr wbcLookupDomainController(const char *domain,
1123 uint32_t flags,
1124 struct wbcDomainControllerInfo **dc_info);
1127 * @brief Get extended domain controller information
1129 * @param domain Name of the domain to query for a DC
1130 * @param guid Guid of the domain to query for a DC
1131 * @param site Site of the domain to query for a DC
1132 * @param flags Bit flags used to control the domain location query
1133 * @param *dc_info Pointer to the returned extended domain controller information
1135 * @return #wbcErr
1137 wbcErr wbcLookupDomainControllerEx(const char *domain,
1138 struct wbcGuid *guid,
1139 const char *site,
1140 uint32_t flags,
1141 struct wbcDomainControllerInfoEx **dc_info);
1143 /**********************************************************
1144 * Athenticate functions
1145 **********************************************************/
1148 * @brief Authenticate a username/password pair
1150 * @param username Name of user to authenticate
1151 * @param password Clear text password os user
1153 * @return #wbcErr
1155 wbcErr wbcAuthenticateUser(const char *username,
1156 const char *password);
1159 * @brief Authenticate with more detailed information
1161 * @param params Input parameters, WBC_AUTH_USER_LEVEL_HASH
1162 * is not supported yet
1163 * @param info Output details on WBC_ERR_SUCCESS
1164 * @param error Output details on WBC_ERR_AUTH_ERROR
1166 * @return #wbcErr
1168 wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params,
1169 struct wbcAuthUserInfo **info,
1170 struct wbcAuthErrorInfo **error);
1173 * @brief Logon a User
1175 * @param[in] params Pointer to a wbcLogonUserParams structure
1176 * @param[out] info Pointer to a pointer to a wbcLogonUserInfo structure
1177 * @param[out] error Pointer to a pointer to a wbcAuthErrorInfo structure
1178 * @param[out] policy Pointer to a pointer to a wbcUserPasswordPolicyInfo structure
1180 * @return #wbcErr
1182 wbcErr wbcLogonUser(const struct wbcLogonUserParams *params,
1183 struct wbcLogonUserInfo **info,
1184 struct wbcAuthErrorInfo **error,
1185 struct wbcUserPasswordPolicyInfo **policy);
1188 * @brief Trigger a logoff notification to Winbind for a specific user
1190 * @param username Name of user to remove from Winbind's list of
1191 * logged on users.
1192 * @param uid Uid assigned to the username
1193 * @param ccfilename Absolute path to the Krb5 credentials cache to
1194 * be removed
1196 * @return #wbcErr
1198 wbcErr wbcLogoffUser(const char *username,
1199 uid_t uid,
1200 const char *ccfilename);
1203 * @brief Trigger an extended logoff notification to Winbind for a specific user
1205 * @param params A wbcLogoffUserParams structure
1206 * @param error User output details on error
1208 * @return #wbcErr
1210 wbcErr wbcLogoffUserEx(const struct wbcLogoffUserParams *params,
1211 struct wbcAuthErrorInfo **error);
1214 * @brief Change a password for a user
1216 * @param username Name of user to authenticate
1217 * @param old_password Old clear text password of user
1218 * @param new_password New clear text password of user
1220 * @return #wbcErr
1222 wbcErr wbcChangeUserPassword(const char *username,
1223 const char *old_password,
1224 const char *new_password);
1227 * @brief Change a password for a user with more detailed information upon
1228 * failure
1230 * @param params Input parameters
1231 * @param error User output details on WBC_ERR_PWD_CHANGE_FAILED
1232 * @param reject_reason New password reject reason on WBC_ERR_PWD_CHANGE_FAILED
1233 * @param policy Password policy output details on WBC_ERR_PWD_CHANGE_FAILED
1235 * @return #wbcErr
1237 wbcErr wbcChangeUserPasswordEx(const struct wbcChangePasswordParams *params,
1238 struct wbcAuthErrorInfo **error,
1239 enum wbcPasswordChangeRejectReason *reject_reason,
1240 struct wbcUserPasswordPolicyInfo **policy);
1243 * @brief Authenticate a user with cached credentials
1245 * @param *params Pointer to a wbcCredentialCacheParams structure
1246 * @param **info Pointer to a pointer to a wbcCredentialCacheInfo structure
1247 * @param **error Pointer to a pointer to a wbcAuthErrorInfo structure
1249 * @return #wbcErr
1251 wbcErr wbcCredentialCache(struct wbcCredentialCacheParams *params,
1252 struct wbcCredentialCacheInfo **info,
1253 struct wbcAuthErrorInfo **error);
1256 * @brief Save a password with winbind for doing wbcCredentialCache() later
1258 * @param *user Username
1259 * @param *password Password
1261 * @return #wbcErr
1263 wbcErr wbcCredentialSave(const char *user, const char *password);
1265 /**********************************************************
1266 * Resolve functions
1267 **********************************************************/
1270 * @brief Resolve a NetbiosName via WINS
1272 * @param name Name to resolve
1273 * @param *ip Pointer to the ip address string
1275 * @return #wbcErr
1277 wbcErr wbcResolveWinsByName(const char *name, char **ip);
1280 * @brief Resolve an IP address via WINS into a NetbiosName
1282 * @param ip The ip address string
1283 * @param *name Pointer to the name
1285 * @return #wbcErr
1288 wbcErr wbcResolveWinsByIP(const char *ip, char **name);
1290 /**********************************************************
1291 * Trusted domain functions
1292 **********************************************************/
1295 * @brief Trigger a verification of the trust credentials of a specific domain
1297 * @param *domain The name of the domain.
1298 * @param error Output details on WBC_ERR_AUTH_ERROR
1300 * @return #wbcErr
1302 wbcErr wbcCheckTrustCredentials(const char *domain,
1303 struct wbcAuthErrorInfo **error);
1306 * @brief Trigger a change of the trust credentials for a specific domain
1308 * @param *domain The name of the domain.
1309 * @param error Output details on WBC_ERR_AUTH_ERROR
1311 * @return #wbcErr
1313 wbcErr wbcChangeTrustCredentials(const char *domain,
1314 struct wbcAuthErrorInfo **error);
1317 * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost
1318 * version of wbcCheckTrustCredentials
1320 * @param *domain The name of the domain, only NULL for the default domain is
1321 * supported yet. Other values than NULL will result in
1322 * WBC_ERR_NOT_IMPLEMENTED.
1323 * @param error Output details on WBC_ERR_AUTH_ERROR
1325 * @return #wbcErr
1327 wbcErr wbcPingDc(const char *domain, struct wbcAuthErrorInfo **error);
1329 /**********************************************************
1330 * Helper functions
1331 **********************************************************/
1334 * @brief Initialize a named blob and add to list of blobs
1336 * @param[in,out] num_blobs Pointer to the number of blobs
1337 * @param[in,out] blobs Pointer to an array of blobs
1338 * @param[in] name Name of the new named blob
1339 * @param[in] flags Flags of the new named blob
1340 * @param[in] data Blob data of new blob
1341 * @param[in] length Blob data length of new blob
1343 * @return #wbcErr
1345 wbcErr wbcAddNamedBlob(size_t *num_blobs,
1346 struct wbcNamedBlob **blobs,
1347 const char *name,
1348 uint32_t flags,
1349 uint8_t *data,
1350 size_t length);
1352 #endif /* _WBCLIENT_H */