2 Unix SMB/CIFS implementation.
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/>.
29 /* Define error types */
32 * @brief Status codes returned from wbc functions
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);
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
70 #define WBCLIENT_MAJOR_VERSION 0
71 #define WBCLIENT_MINOR_VERSION 6
72 #define WBCLIENT_VENDOR_VERSION "Samba libwbclient"
73 struct wbcLibraryDetails {
74 uint16_t major_version;
75 uint16_t minor_version;
76 const char *vendor_version;
80 * @brief Some useful details about the running winbindd
83 struct wbcInterfaceDetails {
84 uint32_t interface_version;
85 char *winbind_version;
86 char winbind_separator;
93 * Data types used by the Winbind Client API
96 #ifndef WBC_MAXSUBAUTHS
97 #define WBC_MAXSUBAUTHS 15 /* max sub authorities in a SID */
101 * @brief Windows Security Identifier
105 struct wbcDomainSid {
109 uint32_t sub_auths[WBC_MAXSUBAUTHS];
113 * @brief Security Identifier type
117 WBC_SID_NAME_USE_NONE=0,
119 WBC_SID_NAME_DOM_GRP=2,
120 WBC_SID_NAME_DOMAIN=3,
121 WBC_SID_NAME_ALIAS=4,
122 WBC_SID_NAME_WKN_GRP=5,
123 WBC_SID_NAME_DELETED=6,
124 WBC_SID_NAME_INVALID=7,
125 WBC_SID_NAME_UNKNOWN=8,
126 WBC_SID_NAME_COMPUTER=9
130 * @brief Security Identifier with attributes
133 struct wbcSidWithAttr {
134 struct wbcDomainSid sid;
138 /* wbcSidWithAttr->attributes */
140 #define WBC_SID_ATTR_GROUP_MANDATORY 0x00000001
141 #define WBC_SID_ATTR_GROUP_ENABLED_BY_DEFAULT 0x00000002
142 #define WBC_SID_ATTR_GROUP_ENABLED 0x00000004
143 #define WBC_SID_ATTR_GROUP_OWNER 0x00000008
144 #define WBC_SID_ATTR_GROUP_USEFOR_DENY_ONLY 0x00000010
145 #define WBC_SID_ATTR_GROUP_RESOURCE 0x20000000
146 #define WBC_SID_ATTR_GROUP_LOGON_ID 0xC0000000
149 * @brief Windows GUID
156 uint16_t time_hi_and_version;
157 uint8_t clock_seq[2];
162 * @brief Domain Information
165 struct wbcDomainInfo {
168 struct wbcDomainSid sid;
169 uint32_t domain_flags;
170 uint32_t trust_flags;
174 /* wbcDomainInfo->domain_flags */
176 #define WBC_DOMINFO_DOMAIN_UNKNOWN 0x00000000
177 #define WBC_DOMINFO_DOMAIN_NATIVE 0x00000001
178 #define WBC_DOMINFO_DOMAIN_AD 0x00000002
179 #define WBC_DOMINFO_DOMAIN_PRIMARY 0x00000004
180 #define WBC_DOMINFO_DOMAIN_OFFLINE 0x00000008
182 /* wbcDomainInfo->trust_flags */
184 #define WBC_DOMINFO_TRUST_TRANSITIVE 0x00000001
185 #define WBC_DOMINFO_TRUST_INCOMING 0x00000002
186 #define WBC_DOMINFO_TRUST_OUTGOING 0x00000004
188 /* wbcDomainInfo->trust_type */
190 #define WBC_DOMINFO_TRUSTTYPE_NONE 0x00000000
191 #define WBC_DOMINFO_TRUSTTYPE_FOREST 0x00000001
192 #define WBC_DOMINFO_TRUSTTYPE_IN_FOREST 0x00000002
193 #define WBC_DOMINFO_TRUSTTYPE_EXTERNAL 0x00000003
197 * @brief Auth User Parameters
200 struct wbcAuthUserParams {
201 const char *account_name;
202 const char *domain_name;
203 const char *workstation_name;
207 uint32_t parameter_control;
209 enum wbcAuthUserLevel {
210 WBC_AUTH_USER_LEVEL_PLAIN = 1,
211 WBC_AUTH_USER_LEVEL_HASH = 2,
212 WBC_AUTH_USER_LEVEL_RESPONSE = 3
215 const char *plaintext;
221 uint8_t challenge[8];
231 * @brief Generic Blob
243 struct wbcNamedBlob {
250 * @brief Logon User Parameters
253 struct wbcLogonUserParams {
254 const char *username;
255 const char *password;
257 struct wbcNamedBlob *blobs;
261 * @brief ChangePassword Parameters
264 struct wbcChangePasswordParams {
265 const char *account_name;
266 const char *domain_name;
270 enum wbcChangePasswordLevel {
271 WBC_CHANGE_PASSWORD_LEVEL_PLAIN = 1,
272 WBC_CHANGE_PASSWORD_LEVEL_RESPONSE = 2
276 const char *plaintext;
278 uint32_t old_nt_hash_enc_length;
279 uint8_t *old_nt_hash_enc_data;
280 uint32_t old_lm_hash_enc_length;
281 uint8_t *old_lm_hash_enc_data;
285 const char *plaintext;
295 /* wbcAuthUserParams->parameter_control */
297 #define WBC_MSV1_0_CLEARTEXT_PASSWORD_ALLOWED 0x00000002
298 #define WBC_MSV1_0_UPDATE_LOGON_STATISTICS 0x00000004
299 #define WBC_MSV1_0_RETURN_USER_PARAMETERS 0x00000008
300 #define WBC_MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT 0x00000020
301 #define WBC_MSV1_0_RETURN_PROFILE_PATH 0x00000200
302 #define WBC_MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT 0x00000800
304 /* wbcAuthUserParams->flags */
306 #define WBC_AUTH_PARAM_FLAGS_INTERACTIVE_LOGON 0x00000001
309 * @brief Auth User Information
311 * Some of the strings are maybe NULL
314 struct wbcAuthUserInfo {
318 char *user_principal;
321 char *dns_domain_name;
324 uint8_t user_session_key[16];
325 uint8_t lm_session_key[8];
327 uint16_t logon_count;
328 uint16_t bad_password_count;
331 uint64_t logoff_time;
332 uint64_t kickoff_time;
333 uint64_t pass_last_set_time;
334 uint64_t pass_can_change_time;
335 uint64_t pass_must_change_time;
340 char *home_directory;
344 * the 1st one is the account sid
345 * the 2nd one is the primary_group sid
346 * followed by the rest of the groups
349 struct wbcSidWithAttr *sids;
353 * @brief Logon User Information
355 * Some of the strings are maybe NULL
358 struct wbcLogonUserInfo {
359 struct wbcAuthUserInfo *info;
361 struct wbcNamedBlob *blobs;
364 /* wbcAuthUserInfo->user_flags */
366 #define WBC_AUTH_USER_INFO_GUEST 0x00000001
367 #define WBC_AUTH_USER_INFO_NOENCRYPTION 0x00000002
368 #define WBC_AUTH_USER_INFO_CACHED_ACCOUNT 0x00000004
369 #define WBC_AUTH_USER_INFO_USED_LM_PASSWORD 0x00000008
370 #define WBC_AUTH_USER_INFO_EXTRA_SIDS 0x00000020
371 #define WBC_AUTH_USER_INFO_SUBAUTH_SESSION_KEY 0x00000040
372 #define WBC_AUTH_USER_INFO_SERVER_TRUST_ACCOUNT 0x00000080
373 #define WBC_AUTH_USER_INFO_NTLMV2_ENABLED 0x00000100
374 #define WBC_AUTH_USER_INFO_RESOURCE_GROUPS 0x00000200
375 #define WBC_AUTH_USER_INFO_PROFILE_PATH_RETURNED 0x00000400
376 #define WBC_AUTH_USER_INFO_GRACE_LOGON 0x01000000
378 /* wbcAuthUserInfo->acct_flags */
380 #define WBC_ACB_DISABLED 0x00000001 /* 1 User account disabled */
381 #define WBC_ACB_HOMDIRREQ 0x00000002 /* 1 Home directory required */
382 #define WBC_ACB_PWNOTREQ 0x00000004 /* 1 User password not required */
383 #define WBC_ACB_TEMPDUP 0x00000008 /* 1 Temporary duplicate account */
384 #define WBC_ACB_NORMAL 0x00000010 /* 1 Normal user account */
385 #define WBC_ACB_MNS 0x00000020 /* 1 MNS logon user account */
386 #define WBC_ACB_DOMTRUST 0x00000040 /* 1 Interdomain trust account */
387 #define WBC_ACB_WSTRUST 0x00000080 /* 1 Workstation trust account */
388 #define WBC_ACB_SVRTRUST 0x00000100 /* 1 Server trust account */
389 #define WBC_ACB_PWNOEXP 0x00000200 /* 1 User password does not expire */
390 #define WBC_ACB_AUTOLOCK 0x00000400 /* 1 Account auto locked */
391 #define WBC_ACB_ENC_TXT_PWD_ALLOWED 0x00000800 /* 1 Encryped text password is allowed */
392 #define WBC_ACB_SMARTCARD_REQUIRED 0x00001000 /* 1 Smart Card required */
393 #define WBC_ACB_TRUSTED_FOR_DELEGATION 0x00002000 /* 1 Trusted for Delegation */
394 #define WBC_ACB_NOT_DELEGATED 0x00004000 /* 1 Not delegated */
395 #define WBC_ACB_USE_DES_KEY_ONLY 0x00008000 /* 1 Use DES key only */
396 #define WBC_ACB_DONT_REQUIRE_PREAUTH 0x00010000 /* 1 Preauth not required */
397 #define WBC_ACB_PW_EXPIRED 0x00020000 /* 1 Password Expired */
398 #define WBC_ACB_NO_AUTH_DATA_REQD 0x00080000 /* 1 = No authorization data required */
400 struct wbcAuthErrorInfo {
404 char *display_string;
408 * @brief User Password Policy Information
411 /* wbcUserPasswordPolicyInfo->password_properties */
413 #define WBC_DOMAIN_PASSWORD_COMPLEX 0x00000001
414 #define WBC_DOMAIN_PASSWORD_NO_ANON_CHANGE 0x00000002
415 #define WBC_DOMAIN_PASSWORD_NO_CLEAR_CHANGE 0x00000004
416 #define WBC_DOMAIN_PASSWORD_LOCKOUT_ADMINS 0x00000008
417 #define WBC_DOMAIN_PASSWORD_STORE_CLEARTEXT 0x00000010
418 #define WBC_DOMAIN_REFUSE_PASSWORD_CHANGE 0x00000020
420 struct wbcUserPasswordPolicyInfo {
421 uint32_t min_length_password;
422 uint32_t password_history;
423 uint32_t password_properties;
425 uint64_t min_passwordage;
429 * @brief Change Password Reject Reason
432 enum wbcPasswordChangeRejectReason {
433 WBC_PWD_CHANGE_NO_ERROR=0,
434 WBC_PWD_CHANGE_PASSWORD_TOO_SHORT=1,
435 WBC_PWD_CHANGE_PWD_IN_HISTORY=2,
436 WBC_PWD_CHANGE_USERNAME_IN_PASSWORD=3,
437 WBC_PWD_CHANGE_FULLNAME_IN_PASSWORD=4,
438 WBC_PWD_CHANGE_NOT_COMPLEX=5,
439 WBC_PWD_CHANGE_MACHINE_NOT_DEFAULT=6,
440 WBC_PWD_CHANGE_FAILED_BY_FILTER=7,
441 WBC_PWD_CHANGE_PASSWORD_TOO_LONG=8
444 /* Note: this defines exist for compatibility reasons with existing code */
445 #define WBC_PWD_CHANGE_REJECT_OTHER WBC_PWD_CHANGE_NO_ERROR
446 #define WBC_PWD_CHANGE_REJECT_TOO_SHORT WBC_PWD_CHANGE_PASSWORD_TOO_SHORT
447 #define WBC_PWD_CHANGE_REJECT_IN_HISTORY WBC_PWD_CHANGE_PWD_IN_HISTORY
448 #define WBC_PWD_CHANGE_REJECT_COMPLEXITY WBC_PWD_CHANGE_NOT_COMPLEX
451 * @brief Logoff User Parameters
454 struct wbcLogoffUserParams {
455 const char *username;
457 struct wbcNamedBlob *blobs;
460 /** @brief Credential cache log-on parameters
464 struct wbcCredentialCacheParams {
465 const char *account_name;
466 const char *domain_name;
467 enum wbcCredentialCacheLevel {
468 WBC_CREDENTIAL_CACHE_LEVEL_NTLMSSP = 1
471 struct wbcNamedBlob *blobs;
475 /** @brief Info returned by credential cache auth
479 struct wbcCredentialCacheInfo {
481 struct wbcNamedBlob *blobs;
485 * DomainControllerInfo struct
487 struct wbcDomainControllerInfo {
492 * DomainControllerInfoEx struct
494 struct wbcDomainControllerInfoEx {
496 const char *dc_address;
497 uint16_t dc_address_type;
498 struct wbcGuid *domain_guid;
499 const char *domain_name;
500 const char *forest_name;
502 const char *dc_site_name;
503 const char *client_site_name;
506 /**********************************************************
508 **********************************************************/
511 * @brief Free library allocated memory
513 * @param * Pointer to free
517 void wbcFreeMemory(void*);
521 * Utility functions for dealing with SIDs
525 * @brief Get a string representation of the SID type
527 * @param type type of the SID
529 * @return string representation of the SID type
531 const char* wbcSidTypeString(enum wbcSidType type);
534 * @brief Convert a binary SID to a character string
536 * @param sid Binary Security Identifier
537 * @param **sid_string Resulting character string
541 wbcErr wbcSidToString(const struct wbcDomainSid *sid,
545 * @brief Convert a character string to a binary SID
547 * @param *sid_string Character string in the form of S-...
548 * @param sid Resulting binary SID
552 wbcErr wbcStringToSid(const char *sid_string,
553 struct wbcDomainSid *sid);
556 * Utility functions for dealing with GUIDs
560 * @brief Convert a binary GUID to a character string
562 * @param guid Binary Guid
563 * @param **guid_string Resulting character string
567 wbcErr wbcGuidToString(const struct wbcGuid *guid,
571 * @brief Convert a character string to a binary GUID
573 * @param *guid_string Character string
574 * @param guid Resulting binary GUID
578 wbcErr wbcStringToGuid(const char *guid_string,
579 struct wbcGuid *guid);
582 * @brief Ping winbindd to see if the daemon is running
586 wbcErr wbcPing(void);
588 wbcErr wbcLibraryDetails(struct wbcLibraryDetails **details);
590 wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **details);
592 /**********************************************************
593 * Name/SID conversion
594 **********************************************************/
597 * @brief Convert a domain and name to SID
599 * @param dom_name Domain name (possibly "")
600 * @param name User or group name
601 * @param *sid Pointer to the resolved domain SID
602 * @param *name_type Pointer to the SID type
606 wbcErr wbcLookupName(const char *dom_name,
608 struct wbcDomainSid *sid,
609 enum wbcSidType *name_type);
612 * @brief Convert a SID to a domain and name
614 * @param *sid Pointer to the domain SID to be resolved
615 * @param domain Resolved Domain name (possibly "")
616 * @param name Resolved User or group name
617 * @param *name_type Pointer to the resolved SID type
621 wbcErr wbcLookupSid(const struct wbcDomainSid *sid,
624 enum wbcSidType *name_type);
627 * @brief Translate a collection of RIDs within a domain to names
629 wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
632 const char **domain_name,
634 enum wbcSidType **types);
637 * @brief Get the groups a user belongs to
639 wbcErr wbcLookupUserSids(const struct wbcDomainSid *user_sid,
640 bool domain_groups_only,
642 struct wbcDomainSid **sids);
645 * @brief Get alias membership for sids
647 wbcErr wbcGetSidAliases(const struct wbcDomainSid *dom_sid,
648 struct wbcDomainSid *sids,
650 uint32_t **alias_rids,
651 uint32_t *num_alias_rids);
656 wbcErr wbcListUsers(const char *domain_name,
658 const char ***users);
661 * @brief Lists Groups
663 wbcErr wbcListGroups(const char *domain_name,
664 uint32_t *num_groups,
665 const char ***groups);
667 wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid,
670 enum wbcSidType *pname_type);
672 /**********************************************************
673 * SID/uid/gid Mappings
674 **********************************************************/
677 * @brief Convert a Windows SID to a Unix uid, allocating an uid if needed
679 * @param *sid Pointer to the domain SID to be resolved
680 * @param *puid Pointer to the resolved uid_t value
685 wbcErr wbcSidToUid(const struct wbcDomainSid *sid,
689 * @brief Convert a Windows SID to a Unix uid if there already is a mapping
691 * @param *sid Pointer to the domain SID to be resolved
692 * @param *puid Pointer to the resolved uid_t value
697 wbcErr wbcQuerySidToUid(const struct wbcDomainSid *sid,
701 * @brief Convert a Unix uid to a Windows SID, allocating a SID if needed
703 * @param uid Unix uid to be resolved
704 * @param *sid Pointer to the resolved domain SID
709 wbcErr wbcUidToSid(uid_t uid,
710 struct wbcDomainSid *sid);
713 * @brief Convert a Unix uid to a Windows SID if there already is a mapping
715 * @param uid Unix uid to be resolved
716 * @param *sid Pointer to the resolved domain SID
721 wbcErr wbcQueryUidToSid(uid_t uid,
722 struct wbcDomainSid *sid);
725 * @brief Convert a Windows SID to a Unix gid, allocating a gid if needed
727 * @param *sid Pointer to the domain SID to be resolved
728 * @param *pgid Pointer to the resolved gid_t value
733 wbcErr wbcSidToGid(const struct wbcDomainSid *sid,
737 * @brief Convert a Windows SID to a Unix gid if there already is a mapping
739 * @param *sid Pointer to the domain SID to be resolved
740 * @param *pgid Pointer to the resolved gid_t value
745 wbcErr wbcQuerySidToGid(const struct wbcDomainSid *sid,
749 * @brief Convert a Unix gid to a Windows SID, allocating a SID if needed
751 * @param gid Unix gid to be resolved
752 * @param *sid Pointer to the resolved domain SID
757 wbcErr wbcGidToSid(gid_t gid,
758 struct wbcDomainSid *sid);
761 * @brief Convert a Unix gid to a Windows SID if there already is a mapping
763 * @param gid Unix gid to be resolved
764 * @param *sid Pointer to the resolved domain SID
769 wbcErr wbcQueryGidToSid(gid_t gid,
770 struct wbcDomainSid *sid);
773 * @brief Obtain a new uid from Winbind
775 * @param *puid *pointer to the allocated uid
779 wbcErr wbcAllocateUid(uid_t *puid);
782 * @brief Obtain a new gid from Winbind
784 * @param *pgid Pointer to the allocated gid
788 wbcErr wbcAllocateGid(gid_t *pgid);
791 * @brief Set an user id mapping
793 * @param uid Uid of the desired mapping.
794 * @param *sid Pointer to the sid of the diresired mapping.
798 wbcErr wbcSetUidMapping(uid_t uid, const struct wbcDomainSid *sid);
801 * @brief Set a group id mapping
803 * @param gid Gid of the desired mapping.
804 * @param *sid Pointer to the sid of the diresired mapping.
808 wbcErr wbcSetGidMapping(gid_t gid, const struct wbcDomainSid *sid);
811 * @brief Remove a user id mapping
813 * @param uid Uid of the mapping to remove.
814 * @param *sid Pointer to the sid of the mapping to remove.
818 wbcErr wbcRemoveUidMapping(uid_t uid, const struct wbcDomainSid *sid);
821 * @brief Remove a group id mapping
823 * @param gid Gid of the mapping to remove.
824 * @param *sid Pointer to the sid of the mapping to remove.
828 wbcErr wbcRemoveGidMapping(gid_t gid, const struct wbcDomainSid *sid);
831 * @brief Set the highwater mark for allocated uids.
833 * @param uid_hwm The new uid highwater mark value
837 wbcErr wbcSetUidHwm(uid_t uid_hwm);
840 * @brief Set the highwater mark for allocated gids.
842 * @param gid_hwm The new gid highwater mark value
846 wbcErr wbcSetGidHwm(gid_t gid_hwm);
848 /**********************************************************
849 * NSS Lookup User/Group details
850 **********************************************************/
853 * @brief Fill in a struct passwd* for a domain user based
856 * @param *name Username to lookup
857 * @param **pwd Pointer to resulting struct passwd* from the query.
861 wbcErr wbcGetpwnam(const char *name, struct passwd **pwd);
864 * @brief Fill in a struct passwd* for a domain user based
867 * @param uid Uid to lookup
868 * @param **pwd Pointer to resulting struct passwd* from the query.
872 wbcErr wbcGetpwuid(uid_t uid, struct passwd **pwd);
875 * @brief Fill in a struct passwd* for a domain user based
878 * @param sid Sid to lookup
879 * @param **pwd Pointer to resulting struct passwd* from the query.
883 wbcErr wbcGetpwsid(struct wbcDomainSid * sid, struct passwd **pwd);
886 * @brief Fill in a struct passwd* for a domain user based
889 * @param *name Username to lookup
890 * @param **grp Pointer to resulting struct group* from the query.
894 wbcErr wbcGetgrnam(const char *name, struct group **grp);
897 * @brief Fill in a struct passwd* for a domain user based
900 * @param gid Uid to lookup
901 * @param **grp Pointer to resulting struct group* from the query.
905 wbcErr wbcGetgrgid(gid_t gid, struct group **grp);
908 * @brief Reset the passwd iterator
912 wbcErr wbcSetpwent(void);
915 * @brief Close the passwd iterator
919 wbcErr wbcEndpwent(void);
922 * @brief Return the next struct passwd* entry from the pwent iterator
924 * @param **pwd Pointer to resulting struct passwd* from the query.
928 wbcErr wbcGetpwent(struct passwd **pwd);
931 * @brief Reset the group iterator
935 wbcErr wbcSetgrent(void);
938 * @brief Close the group iterator
942 wbcErr wbcEndgrent(void);
945 * @brief Return the next struct group* entry from the pwent iterator
947 * @param **grp Pointer to resulting struct group* from the query.
951 wbcErr wbcGetgrent(struct group **grp);
954 * @brief Return the next struct group* entry from the pwent iterator
956 * This is similar to #wbcGetgrent, just that the member list is empty
958 * @param **grp Pointer to resulting struct group* from the query.
962 wbcErr wbcGetgrlist(struct group **grp);
965 * @brief Return the unix group array belonging to the given user
967 * @param *account The given user name
968 * @param *num_groups Number of elements returned in the groups array
969 * @param **_groups Pointer to resulting gid_t array.
973 wbcErr wbcGetGroups(const char *account,
974 uint32_t *num_groups,
978 /**********************************************************
979 * Lookup Domain information
980 **********************************************************/
983 * @brief Lookup the current status of a trusted domain
985 * @param domain Domain to query
986 * @param *info Pointer to returned domain_info struct
990 wbcErr wbcDomainInfo(const char *domain,
991 struct wbcDomainInfo **info);
994 * @brief Enumerate the domain trusts known by Winbind
996 * @param **domains Pointer to the allocated domain list array
997 * @param *num_domains Pointer to number of domains returned
1001 wbcErr wbcListTrusts(struct wbcDomainInfo **domains,
1002 size_t *num_domains);
1004 /* Flags for wbcLookupDomainController */
1006 #define WBC_LOOKUP_DC_FORCE_REDISCOVERY 0x00000001
1007 #define WBC_LOOKUP_DC_DS_REQUIRED 0x00000010
1008 #define WBC_LOOKUP_DC_DS_PREFERRED 0x00000020
1009 #define WBC_LOOKUP_DC_GC_SERVER_REQUIRED 0x00000040
1010 #define WBC_LOOKUP_DC_PDC_REQUIRED 0x00000080
1011 #define WBC_LOOKUP_DC_BACKGROUND_ONLY 0x00000100
1012 #define WBC_LOOKUP_DC_IP_REQUIRED 0x00000200
1013 #define WBC_LOOKUP_DC_KDC_REQUIRED 0x00000400
1014 #define WBC_LOOKUP_DC_TIMESERV_REQUIRED 0x00000800
1015 #define WBC_LOOKUP_DC_WRITABLE_REQUIRED 0x00001000
1016 #define WBC_LOOKUP_DC_GOOD_TIMESERV_PREFERRED 0x00002000
1017 #define WBC_LOOKUP_DC_AVOID_SELF 0x00004000
1018 #define WBC_LOOKUP_DC_ONLY_LDAP_NEEDED 0x00008000
1019 #define WBC_LOOKUP_DC_IS_FLAT_NAME 0x00010000
1020 #define WBC_LOOKUP_DC_IS_DNS_NAME 0x00020000
1021 #define WBC_LOOKUP_DC_TRY_NEXTCLOSEST_SITE 0x00040000
1022 #define WBC_LOOKUP_DC_DS_6_REQUIRED 0x00080000
1023 #define WBC_LOOKUP_DC_RETURN_DNS_NAME 0x40000000
1024 #define WBC_LOOKUP_DC_RETURN_FLAT_NAME 0x80000000
1027 * @brief Enumerate the domain trusts known by Winbind
1029 * @param domain Name of the domain to query for a DC
1030 * @param flags Bit flags used to control the domain location query
1031 * @param *dc_info Pointer to the returned domain controller information
1035 wbcErr wbcLookupDomainController(const char *domain,
1037 struct wbcDomainControllerInfo **dc_info);
1040 * @brief Get extended domain controller information
1042 * @param domain Name of the domain to query for a DC
1043 * @param guid Guid of the domain to query for a DC
1044 * @param site Site of the domain to query for a DC
1045 * @param flags Bit flags used to control the domain location query
1046 * @param *dc_info Pointer to the returned extended domain controller information
1050 wbcErr wbcLookupDomainControllerEx(const char *domain,
1051 struct wbcGuid *guid,
1054 struct wbcDomainControllerInfoEx **dc_info);
1056 /**********************************************************
1057 * Athenticate functions
1058 **********************************************************/
1061 * @brief Authenticate a username/password pair
1063 * @param username Name of user to authenticate
1064 * @param password Clear text password os user
1068 wbcErr wbcAuthenticateUser(const char *username,
1069 const char *password);
1072 * @brief Authenticate with more detailed information
1074 * @param params Input parameters, WBC_AUTH_USER_LEVEL_HASH
1075 * is not supported yet
1076 * @param info Output details on WBC_ERR_SUCCESS
1077 * @param error Output details on WBC_ERR_AUTH_ERROR
1081 wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params,
1082 struct wbcAuthUserInfo **info,
1083 struct wbcAuthErrorInfo **error);
1086 * @brief Logon a User
1088 * @param[in] params Pointer to a wbcLogonUserParams structure
1089 * @param[out] info Pointer to a pointer to a wbcLogonUserInfo structure
1090 * @param[out] error Pointer to a pointer to a wbcAuthErrorInfo structure
1091 * @param[out] policy Pointer to a pointer to a wbcUserPasswordPolicyInfo structure
1095 wbcErr wbcLogonUser(const struct wbcLogonUserParams *params,
1096 struct wbcLogonUserInfo **info,
1097 struct wbcAuthErrorInfo **error,
1098 struct wbcUserPasswordPolicyInfo **policy);
1101 * @brief Trigger a logoff notification to Winbind for a specific user
1103 * @param username Name of user to remove from Winbind's list of
1105 * @param uid Uid assigned to the username
1106 * @param ccfilename Absolute path to the Krb5 credentials cache to
1111 wbcErr wbcLogoffUser(const char *username,
1113 const char *ccfilename);
1116 * @brief Trigger an extended logoff notification to Winbind for a specific user
1118 * @param params A wbcLogoffUserParams structure
1119 * @param error User output details on error
1123 wbcErr wbcLogoffUserEx(const struct wbcLogoffUserParams *params,
1124 struct wbcAuthErrorInfo **error);
1127 * @brief Change a password for a user
1129 * @param username Name of user to authenticate
1130 * @param old_password Old clear text password of user
1131 * @param new_password New clear text password of user
1135 wbcErr wbcChangeUserPassword(const char *username,
1136 const char *old_password,
1137 const char *new_password);
1140 * @brief Change a password for a user with more detailed information upon
1143 * @param params Input parameters
1144 * @param error User output details on WBC_ERR_PWD_CHANGE_FAILED
1145 * @param reject_reason New password reject reason on WBC_ERR_PWD_CHANGE_FAILED
1146 * @param policy Password policy output details on WBC_ERR_PWD_CHANGE_FAILED
1150 wbcErr wbcChangeUserPasswordEx(const struct wbcChangePasswordParams *params,
1151 struct wbcAuthErrorInfo **error,
1152 enum wbcPasswordChangeRejectReason *reject_reason,
1153 struct wbcUserPasswordPolicyInfo **policy);
1156 * @brief Authenticate a user with cached credentials
1158 * @param *params Pointer to a wbcCredentialCacheParams structure
1159 * @param **info Pointer to a pointer to a wbcCredentialCacheInfo structure
1160 * @param **error Pointer to a pointer to a wbcAuthErrorInfo structure
1164 wbcErr wbcCredentialCache(struct wbcCredentialCacheParams *params,
1165 struct wbcCredentialCacheInfo **info,
1166 struct wbcAuthErrorInfo **error);
1169 * @brief Save a password with winbind for doing wbcCredentialCache() later
1171 * @param *user Username
1172 * @param *password Password
1176 wbcErr wbcCredentialSave(const char *user, const char *password);
1178 /**********************************************************
1180 **********************************************************/
1183 * @brief Resolve a NetbiosName via WINS
1185 * @param name Name to resolve
1186 * @param *ip Pointer to the ip address string
1190 wbcErr wbcResolveWinsByName(const char *name, char **ip);
1193 * @brief Resolve an IP address via WINS into a NetbiosName
1195 * @param ip The ip address string
1196 * @param *name Pointer to the name
1201 wbcErr wbcResolveWinsByIP(const char *ip, char **name);
1203 /**********************************************************
1204 * Trusted domain functions
1205 **********************************************************/
1208 * @brief Trigger a verification of the trust credentials of a specific domain
1210 * @param *domain The name of the domain.
1211 * @param error Output details on WBC_ERR_AUTH_ERROR
1215 wbcErr wbcCheckTrustCredentials(const char *domain,
1216 struct wbcAuthErrorInfo **error);
1219 * @brief Trigger a change of the trust credentials for a specific domain
1221 * @param *domain The name of the domain.
1222 * @param error Output details on WBC_ERR_AUTH_ERROR
1226 wbcErr wbcChangeTrustCredentials(const char *domain,
1227 struct wbcAuthErrorInfo **error);
1230 * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost
1231 * version of wbcCheckTrustCredentials
1233 * @param *domain The name of the domain, only NULL for the default domain is
1234 * supported yet. Other values than NULL will result in
1235 * WBC_ERR_NOT_IMPLEMENTED.
1236 * @param error Output details on WBC_ERR_AUTH_ERROR
1240 wbcErr wbcPingDc(const char *domain, struct wbcAuthErrorInfo **error);
1242 /**********************************************************
1244 **********************************************************/
1247 * @brief Initialize a named blob and add to list of blobs
1249 * @param[in,out] num_blobs Pointer to the number of blobs
1250 * @param[in,out] blobs Pointer to an array of blobs
1251 * @param[in] name Name of the new named blob
1252 * @param[in] flags Flags of the new named blob
1253 * @param[in] data Blob data of new blob
1254 * @param[in] length Blob data length of new blob
1258 wbcErr wbcAddNamedBlob(size_t *num_blobs,
1259 struct wbcNamedBlob **blobs,
1265 #endif /* _WBCLIENT_H */