2 Unix SMB/CIFS implementation.
6 Copyright (C) Gerald (Jerry) Carter 2007
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 3 of the License, or (at your option) any later version.
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
28 /* Define error types */
31 * @brief Status codes returned from wbc functions
35 WBC_ERR_SUCCESS
= 0, /**< Successful completion **/
36 WBC_ERR_NOT_IMPLEMENTED
,/**< Function not implemented **/
37 WBC_ERR_UNKNOWN_FAILURE
,/**< General failure **/
38 WBC_ERR_NO_MEMORY
, /**< Memory allocation error **/
39 WBC_ERR_INVALID_SID
, /**< Invalid SID format **/
40 WBC_ERR_INVALID_PARAM
, /**< An Invalid parameter was supplied **/
41 WBC_ERR_WINBIND_NOT_AVAILABLE
, /**< Winbind daemon is not available **/
42 WBC_ERR_DOMAIN_NOT_FOUND
, /**< Domain is not trusted or cannot be found **/
43 WBC_ERR_INVALID_RESPONSE
, /**< Winbind returned an invalid response **/
44 WBC_ERR_NSS_ERROR
, /**< NSS_STATUS error **/
45 WBC_ERR_AUTH_ERROR
, /**< Authentication failed **/
46 WBC_ERR_UNKNOWN_USER
, /**< User account cannot be found */
47 WBC_ERR_UNKNOWN_GROUP
, /**< Group account cannot be found */
48 WBC_ERR_PWD_CHANGE_FAILED
/**< Password Change has failed */
51 typedef enum _wbcErrType wbcErr
;
53 #define WBC_ERROR_IS_OK(x) ((x) == WBC_ERR_SUCCESS)
55 const char *wbcErrorString(wbcErr error
);
58 * @brief Some useful details about the wbclient library
60 * 0.1: Initial version
61 * 0.2: Added wbcRemoveUidMapping()
62 * Added wbcRemoveGidMapping()
63 * 0.3: Added wbcGetpwsid()
64 * Added wbcGetSidAliases()
66 #define WBCLIENT_MAJOR_VERSION 0
67 #define WBCLIENT_MINOR_VERSION 3
68 #define WBCLIENT_VENDOR_VERSION "Samba libwbclient"
69 struct wbcLibraryDetails
{
70 uint16_t major_version
;
71 uint16_t minor_version
;
72 const char *vendor_version
;
76 * @brief Some useful details about the running winbindd
79 struct wbcInterfaceDetails
{
80 uint32_t interface_version
;
81 const char *winbind_version
;
82 char winbind_separator
;
83 const char *netbios_name
;
84 const char *netbios_domain
;
85 const char *dns_domain
;
89 * Data types used by the Winbind Client API
92 #ifndef WBC_MAXSUBAUTHS
93 #define WBC_MAXSUBAUTHS 15 /* max sub authorities in a SID */
97 * @brief Windows Security Identifier
101 struct wbcDomainSid
{
105 uint32_t sub_auths
[WBC_MAXSUBAUTHS
];
109 * @brief Security Identifier type
113 WBC_SID_NAME_USE_NONE
=0,
115 WBC_SID_NAME_DOM_GRP
=2,
116 WBC_SID_NAME_DOMAIN
=3,
117 WBC_SID_NAME_ALIAS
=4,
118 WBC_SID_NAME_WKN_GRP
=5,
119 WBC_SID_NAME_DELETED
=6,
120 WBC_SID_NAME_INVALID
=7,
121 WBC_SID_NAME_UNKNOWN
=8,
122 WBC_SID_NAME_COMPUTER
=9
126 * @brief Security Identifier with attributes
129 struct wbcSidWithAttr
{
130 struct wbcDomainSid sid
;
134 /* wbcSidWithAttr->attributes */
136 #define WBC_SID_ATTR_GROUP_MANDATORY 0x00000001
137 #define WBC_SID_ATTR_GROUP_ENABLED_BY_DEFAULT 0x00000002
138 #define WBC_SID_ATTR_GROUP_ENABLED 0x00000004
139 #define WBC_SID_ATTR_GROUP_OWNER 0x00000008
140 #define WBC_SID_ATTR_GROUP_USEFOR_DENY_ONLY 0x00000010
141 #define WBC_SID_ATTR_GROUP_RESOURCE 0x20000000
142 #define WBC_SID_ATTR_GROUP_LOGON_ID 0xC0000000
145 * @brief Windows GUID
152 uint16_t time_hi_and_version
;
153 uint8_t clock_seq
[2];
158 * @brief Domain Information
161 struct wbcDomainInfo
{
164 struct wbcDomainSid sid
;
165 uint32_t domain_flags
;
166 uint32_t trust_flags
;
170 /* wbcDomainInfo->domain_flags */
172 #define WBC_DOMINFO_DOMAIN_UNKNOWN 0x00000000
173 #define WBC_DOMINFO_DOMAIN_NATIVE 0x00000001
174 #define WBC_DOMINFO_DOMAIN_AD 0x00000002
175 #define WBC_DOMINFO_DOMAIN_PRIMARY 0x00000004
176 #define WBC_DOMINFO_DOMAIN_OFFLINE 0x00000008
178 /* wbcDomainInfo->trust_flags */
180 #define WBC_DOMINFO_TRUST_TRANSITIVE 0x00000001
181 #define WBC_DOMINFO_TRUST_INCOMING 0x00000002
182 #define WBC_DOMINFO_TRUST_OUTGOING 0x00000004
184 /* wbcDomainInfo->trust_type */
186 #define WBC_DOMINFO_TRUSTTYPE_NONE 0x00000000
187 #define WBC_DOMINFO_TRUSTTYPE_FOREST 0x00000001
188 #define WBC_DOMINFO_TRUSTTYPE_IN_FOREST 0x00000002
189 #define WBC_DOMINFO_TRUSTTYPE_EXTERNAL 0x00000003
193 * @brief Auth User Parameters
196 struct wbcAuthUserParams
{
197 const char *account_name
;
198 const char *domain_name
;
199 const char *workstation_name
;
203 uint32_t parameter_control
;
205 enum wbcAuthUserLevel
{
206 WBC_AUTH_USER_LEVEL_PLAIN
= 1,
207 WBC_AUTH_USER_LEVEL_HASH
= 2,
208 WBC_AUTH_USER_LEVEL_RESPONSE
= 3
211 const char *plaintext
;
217 uint8_t challenge
[8];
227 * @brief Generic Blob
239 struct wbcNamedBlob
{
246 * @brief Logon User Parameters
249 struct wbcLogonUserParams
{
250 const char *username
;
251 const char *password
;
253 struct wbcNamedBlob
*blobs
;
257 * @brief ChangePassword Parameters
260 struct wbcChangePasswordParams
{
261 const char *account_name
;
262 const char *domain_name
;
266 enum wbcChangePasswordLevel
{
267 WBC_CHANGE_PASSWORD_LEVEL_PLAIN
= 1,
268 WBC_CHANGE_PASSWORD_LEVEL_RESPONSE
= 2
272 const char *plaintext
;
274 uint32_t old_nt_hash_enc_length
;
275 uint8_t *old_nt_hash_enc_data
;
276 uint32_t old_lm_hash_enc_length
;
277 uint8_t *old_lm_hash_enc_data
;
281 const char *plaintext
;
291 /* wbcAuthUserParams->parameter_control */
293 #define WBC_MSV1_0_CLEARTEXT_PASSWORD_ALLOWED 0x00000002
294 #define WBC_MSV1_0_UPDATE_LOGON_STATISTICS 0x00000004
295 #define WBC_MSV1_0_RETURN_USER_PARAMETERS 0x00000008
296 #define WBC_MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT 0x00000020
297 #define WBC_MSV1_0_RETURN_PROFILE_PATH 0x00000200
298 #define WBC_MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT 0x00000800
300 /* wbcAuthUserParams->flags */
302 #define WBC_AUTH_PARAM_FLAGS_INTERACTIVE_LOGON 0x00000001
305 * @brief Auth User Information
307 * Some of the strings are maybe NULL
310 struct wbcAuthUserInfo
{
314 char *user_principal
;
317 char *dns_domain_name
;
320 uint8_t user_session_key
[16];
321 uint8_t lm_session_key
[8];
323 uint16_t logon_count
;
324 uint16_t bad_password_count
;
327 uint64_t logoff_time
;
328 uint64_t kickoff_time
;
329 uint64_t pass_last_set_time
;
330 uint64_t pass_can_change_time
;
331 uint64_t pass_must_change_time
;
336 char *home_directory
;
340 * the 1st one is the account sid
341 * the 2nd one is the primary_group sid
342 * followed by the rest of the groups
345 struct wbcSidWithAttr
*sids
;
349 * @brief Logon User Information
351 * Some of the strings are maybe NULL
354 struct wbcLogonUserInfo
{
355 struct wbcAuthUserInfo
*info
;
357 struct wbcNamedBlob
*blobs
;
360 /* wbcAuthUserInfo->user_flags */
362 #define WBC_AUTH_USER_INFO_GUEST 0x00000001
363 #define WBC_AUTH_USER_INFO_NOENCRYPTION 0x00000002
364 #define WBC_AUTH_USER_INFO_CACHED_ACCOUNT 0x00000004
365 #define WBC_AUTH_USER_INFO_USED_LM_PASSWORD 0x00000008
366 #define WBC_AUTH_USER_INFO_EXTRA_SIDS 0x00000020
367 #define WBC_AUTH_USER_INFO_SUBAUTH_SESSION_KEY 0x00000040
368 #define WBC_AUTH_USER_INFO_SERVER_TRUST_ACCOUNT 0x00000080
369 #define WBC_AUTH_USER_INFO_NTLMV2_ENABLED 0x00000100
370 #define WBC_AUTH_USER_INFO_RESOURCE_GROUPS 0x00000200
371 #define WBC_AUTH_USER_INFO_PROFILE_PATH_RETURNED 0x00000400
372 #define WBC_AUTH_USER_INFO_GRACE_LOGON 0x01000000
374 /* wbcAuthUserInfo->acct_flags */
376 #define WBC_ACB_DISABLED 0x00000001 /* 1 User account disabled */
377 #define WBC_ACB_HOMDIRREQ 0x00000002 /* 1 Home directory required */
378 #define WBC_ACB_PWNOTREQ 0x00000004 /* 1 User password not required */
379 #define WBC_ACB_TEMPDUP 0x00000008 /* 1 Temporary duplicate account */
380 #define WBC_ACB_NORMAL 0x00000010 /* 1 Normal user account */
381 #define WBC_ACB_MNS 0x00000020 /* 1 MNS logon user account */
382 #define WBC_ACB_DOMTRUST 0x00000040 /* 1 Interdomain trust account */
383 #define WBC_ACB_WSTRUST 0x00000080 /* 1 Workstation trust account */
384 #define WBC_ACB_SVRTRUST 0x00000100 /* 1 Server trust account */
385 #define WBC_ACB_PWNOEXP 0x00000200 /* 1 User password does not expire */
386 #define WBC_ACB_AUTOLOCK 0x00000400 /* 1 Account auto locked */
387 #define WBC_ACB_ENC_TXT_PWD_ALLOWED 0x00000800 /* 1 Encryped text password is allowed */
388 #define WBC_ACB_SMARTCARD_REQUIRED 0x00001000 /* 1 Smart Card required */
389 #define WBC_ACB_TRUSTED_FOR_DELEGATION 0x00002000 /* 1 Trusted for Delegation */
390 #define WBC_ACB_NOT_DELEGATED 0x00004000 /* 1 Not delegated */
391 #define WBC_ACB_USE_DES_KEY_ONLY 0x00008000 /* 1 Use DES key only */
392 #define WBC_ACB_DONT_REQUIRE_PREAUTH 0x00010000 /* 1 Preauth not required */
393 #define WBC_ACB_PW_EXPIRED 0x00020000 /* 1 Password Expired */
394 #define WBC_ACB_NO_AUTH_DATA_REQD 0x00080000 /* 1 = No authorization data required */
396 struct wbcAuthErrorInfo
{
400 char *display_string
;
404 * @brief User Password Policy Information
407 /* wbcUserPasswordPolicyInfo->password_properties */
409 #define WBC_DOMAIN_PASSWORD_COMPLEX 0x00000001
410 #define WBC_DOMAIN_PASSWORD_NO_ANON_CHANGE 0x00000002
411 #define WBC_DOMAIN_PASSWORD_NO_CLEAR_CHANGE 0x00000004
412 #define WBC_DOMAIN_PASSWORD_LOCKOUT_ADMINS 0x00000008
413 #define WBC_DOMAIN_PASSWORD_STORE_CLEARTEXT 0x00000010
414 #define WBC_DOMAIN_REFUSE_PASSWORD_CHANGE 0x00000020
416 struct wbcUserPasswordPolicyInfo
{
417 uint32_t min_length_password
;
418 uint32_t password_history
;
419 uint32_t password_properties
;
421 uint64_t min_passwordage
;
425 * @brief Change Password Reject Reason
428 enum wbcPasswordChangeRejectReason
{
429 WBC_PWD_CHANGE_REJECT_OTHER
=0,
430 WBC_PWD_CHANGE_REJECT_TOO_SHORT
=1,
431 WBC_PWD_CHANGE_REJECT_IN_HISTORY
=2,
432 WBC_PWD_CHANGE_REJECT_COMPLEXITY
=5
436 * @brief Logoff User Parameters
439 struct wbcLogoffUserParams
{
440 const char *username
;
442 struct wbcNamedBlob
*blobs
;
445 /** @brief Credential cache log-on parameters
449 struct wbcCredentialCacheParams
{
450 const char *account_name
;
451 const char *domain_name
;
452 enum wbcCredentialCacheLevel
{
453 WBC_CREDENTIAL_CACHE_LEVEL_NTLMSSP
= 1
456 struct wbcNamedBlob
*blobs
;
460 /** @brief Info returned by credential cache auth
464 struct wbcCredentialCacheInfo
{
466 struct wbcNamedBlob
*blobs
;
470 * DomainControllerInfo struct
472 struct wbcDomainControllerInfo
{
477 * DomainControllerInfoEx struct
479 struct wbcDomainControllerInfoEx
{
481 const char *dc_address
;
482 uint16_t dc_address_type
;
483 struct wbcGuid
*domain_guid
;
484 const char *domain_name
;
485 const char *forest_name
;
487 const char *dc_site_name
;
488 const char *client_site_name
;
491 /**********************************************************
493 **********************************************************/
496 * @brief Free library allocated memory
498 * @param * Pointer to free
502 void wbcFreeMemory(void*);
506 * Utility functions for dealing with SIDs
510 * @brief Convert a binary SID to a character string
512 * @param sid Binary Security Identifier
513 * @param **sid_string Resulting character string
517 wbcErr
wbcSidToString(const struct wbcDomainSid
*sid
,
521 * @brief Convert a character string to a binary SID
523 * @param *sid_string Character string in the form of S-...
524 * @param sid Resulting binary SID
528 wbcErr
wbcStringToSid(const char *sid_string
,
529 struct wbcDomainSid
*sid
);
532 * Utility functions for dealing with GUIDs
536 * @brief Convert a binary GUID to a character string
538 * @param guid Binary Guid
539 * @param **guid_string Resulting character string
543 wbcErr
wbcGuidToString(const struct wbcGuid
*guid
,
547 * @brief Convert a character string to a binary GUID
549 * @param *guid_string Character string
550 * @param guid Resulting binary GUID
554 wbcErr
wbcStringToGuid(const char *guid_string
,
555 struct wbcGuid
*guid
);
558 * @brief Ping winbindd to see if the daemon is running
562 wbcErr
wbcPing(void);
564 wbcErr
wbcLibraryDetails(struct wbcLibraryDetails
**details
);
566 wbcErr
wbcInterfaceDetails(struct wbcInterfaceDetails
**details
);
568 /**********************************************************
569 * Name/SID conversion
570 **********************************************************/
573 * @brief Convert a domain and name to SID
575 * @param dom_name Domain name (possibly "")
576 * @param name User or group name
577 * @param *sid Pointer to the resolved domain SID
578 * @param *name_type Pointer to the SID type
582 wbcErr
wbcLookupName(const char *dom_name
,
584 struct wbcDomainSid
*sid
,
585 enum wbcSidType
*name_type
);
588 * @brief Convert a SID to a domain and name
590 * @param *sid Pointer to the domain SID to be resolved
591 * @param domain Resolved Domain name (possibly "")
592 * @param name Resolved User or group name
593 * @param *name_type Pointer to the resolved SID type
597 wbcErr
wbcLookupSid(const struct wbcDomainSid
*sid
,
600 enum wbcSidType
*name_type
);
603 * @brief Translate a collection of RIDs within a domain to names
605 wbcErr
wbcLookupRids(struct wbcDomainSid
*dom_sid
,
608 const char **domain_name
,
610 enum wbcSidType
**types
);
613 * @brief Get the groups a user belongs to
615 wbcErr
wbcLookupUserSids(const struct wbcDomainSid
*user_sid
,
616 bool domain_groups_only
,
618 struct wbcDomainSid
**sids
);
621 * @brief Get alias membership for sids
623 wbcErr
wbcGetSidAliases(const struct wbcDomainSid
*dom_sid
,
624 struct wbcDomainSid
*sids
,
626 uint32_t **alias_rids
,
627 uint32_t *num_alias_rids
);
632 wbcErr
wbcListUsers(const char *domain_name
,
634 const char ***users
);
637 * @brief Lists Groups
639 wbcErr
wbcListGroups(const char *domain_name
,
640 uint32_t *num_groups
,
641 const char ***groups
);
643 wbcErr
wbcGetDisplayName(const struct wbcDomainSid
*sid
,
646 enum wbcSidType
*pname_type
);
648 /**********************************************************
649 * SID/uid/gid Mappings
650 **********************************************************/
653 * @brief Convert a Windows SID to a Unix uid, allocating an uid if needed
655 * @param *sid Pointer to the domain SID to be resolved
656 * @param *puid Pointer to the resolved uid_t value
661 wbcErr
wbcSidToUid(const struct wbcDomainSid
*sid
,
665 * @brief Convert a Windows SID to a Unix uid if there already is a mapping
667 * @param *sid Pointer to the domain SID to be resolved
668 * @param *puid Pointer to the resolved uid_t value
673 wbcErr
wbcQuerySidToUid(const struct wbcDomainSid
*sid
,
677 * @brief Convert a Unix uid to a Windows SID, allocating a SID if needed
679 * @param uid Unix uid to be resolved
680 * @param *sid Pointer to the resolved domain SID
685 wbcErr
wbcUidToSid(uid_t uid
,
686 struct wbcDomainSid
*sid
);
689 * @brief Convert a Unix uid to a Windows SID if there already is a mapping
691 * @param uid Unix uid to be resolved
692 * @param *sid Pointer to the resolved domain SID
697 wbcErr
wbcQueryUidToSid(uid_t uid
,
698 struct wbcDomainSid
*sid
);
701 * @brief Convert a Windows SID to a Unix gid, allocating a gid if needed
703 * @param *sid Pointer to the domain SID to be resolved
704 * @param *pgid Pointer to the resolved gid_t value
709 wbcErr
wbcSidToGid(const struct wbcDomainSid
*sid
,
713 * @brief Convert a Windows SID to a Unix gid if there already is a mapping
715 * @param *sid Pointer to the domain SID to be resolved
716 * @param *pgid Pointer to the resolved gid_t value
721 wbcErr
wbcQuerySidToGid(const struct wbcDomainSid
*sid
,
725 * @brief Convert a Unix gid to a Windows SID, allocating a SID if needed
727 * @param gid Unix gid to be resolved
728 * @param *sid Pointer to the resolved domain SID
733 wbcErr
wbcGidToSid(gid_t gid
,
734 struct wbcDomainSid
*sid
);
737 * @brief Convert a Unix gid to a Windows SID if there already is a mapping
739 * @param gid Unix gid to be resolved
740 * @param *sid Pointer to the resolved domain SID
745 wbcErr
wbcQueryGidToSid(gid_t gid
,
746 struct wbcDomainSid
*sid
);
749 * @brief Obtain a new uid from Winbind
751 * @param *puid *pointer to the allocated uid
755 wbcErr
wbcAllocateUid(uid_t
*puid
);
758 * @brief Obtain a new gid from Winbind
760 * @param *pgid Pointer to the allocated gid
764 wbcErr
wbcAllocateGid(gid_t
*pgid
);
767 * @brief Set an user id mapping
769 * @param uid Uid of the desired mapping.
770 * @param *sid Pointer to the sid of the diresired mapping.
774 wbcErr
wbcSetUidMapping(uid_t uid
, const struct wbcDomainSid
*sid
);
777 * @brief Set a group id mapping
779 * @param gid Gid of the desired mapping.
780 * @param *sid Pointer to the sid of the diresired mapping.
784 wbcErr
wbcSetGidMapping(gid_t gid
, const struct wbcDomainSid
*sid
);
787 * @brief Remove a user id mapping
789 * @param uid Uid of the mapping to remove.
790 * @param *sid Pointer to the sid of the mapping to remove.
794 wbcErr
wbcRemoveUidMapping(uid_t uid
, const struct wbcDomainSid
*sid
);
797 * @brief Remove a group id mapping
799 * @param gid Gid of the mapping to remove.
800 * @param *sid Pointer to the sid of the mapping to remove.
804 wbcErr
wbcRemoveGidMapping(gid_t gid
, const struct wbcDomainSid
*sid
);
807 * @brief Set the highwater mark for allocated uids.
809 * @param uid_hwm The new uid highwater mark value
813 wbcErr
wbcSetUidHwm(uid_t uid_hwm
);
816 * @brief Set the highwater mark for allocated gids.
818 * @param gid_hwm The new gid highwater mark value
822 wbcErr
wbcSetGidHwm(gid_t gid_hwm
);
824 /**********************************************************
825 * NSS Lookup User/Group details
826 **********************************************************/
829 * @brief Fill in a struct passwd* for a domain user based
832 * @param *name Username to lookup
833 * @param **pwd Pointer to resulting struct passwd* from the query.
837 wbcErr
wbcGetpwnam(const char *name
, struct passwd
**pwd
);
840 * @brief Fill in a struct passwd* for a domain user based
843 * @param uid Uid to lookup
844 * @param **pwd Pointer to resulting struct passwd* from the query.
848 wbcErr
wbcGetpwuid(uid_t uid
, struct passwd
**pwd
);
851 * @brief Fill in a struct passwd* for a domain user based
854 * @param sid Sid to lookup
855 * @param **pwd Pointer to resulting struct passwd* from the query.
859 wbcErr
wbcGetpwsid(struct wbcDomainSid
* sid
, struct passwd
**pwd
);
862 * @brief Fill in a struct passwd* for a domain user based
865 * @param *name Username to lookup
866 * @param **grp Pointer to resulting struct group* from the query.
870 wbcErr
wbcGetgrnam(const char *name
, struct group
**grp
);
873 * @brief Fill in a struct passwd* for a domain user based
876 * @param gid Uid to lookup
877 * @param **grp Pointer to resulting struct group* from the query.
881 wbcErr
wbcGetgrgid(gid_t gid
, struct group
**grp
);
884 * @brief Reset the passwd iterator
888 wbcErr
wbcSetpwent(void);
891 * @brief Close the passwd iterator
895 wbcErr
wbcEndpwent(void);
898 * @brief Return the next struct passwd* entry from the pwent iterator
900 * @param **pwd Pointer to resulting struct passwd* from the query.
904 wbcErr
wbcGetpwent(struct passwd
**pwd
);
907 * @brief Reset the group iterator
911 wbcErr
wbcSetgrent(void);
914 * @brief Close the group iterator
918 wbcErr
wbcEndgrent(void);
921 * @brief Return the next struct group* entry from the pwent iterator
923 * @param **grp Pointer to resulting struct group* from the query.
927 wbcErr
wbcGetgrent(struct group
**grp
);
930 * @brief Return the next struct group* entry from the pwent iterator
932 * This is similar to #wbcGetgrent, just that the member list is empty
934 * @param **grp Pointer to resulting struct group* from the query.
938 wbcErr
wbcGetgrlist(struct group
**grp
);
941 * @brief Return the unix group array belonging to the given user
943 * @param *account The given user name
944 * @param *num_groups Number of elements returned in the groups array
945 * @param **_groups Pointer to resulting gid_t array.
949 wbcErr
wbcGetGroups(const char *account
,
950 uint32_t *num_groups
,
954 /**********************************************************
955 * Lookup Domain information
956 **********************************************************/
959 * @brief Lookup the current status of a trusted domain
961 * @param domain Domain to query
962 * @param *info Pointer to returned domain_info struct
966 wbcErr
wbcDomainInfo(const char *domain
,
967 struct wbcDomainInfo
**info
);
970 * @brief Enumerate the domain trusts known by Winbind
972 * @param **domains Pointer to the allocated domain list array
973 * @param *num_domains Pointer to number of domains returned
977 wbcErr
wbcListTrusts(struct wbcDomainInfo
**domains
,
978 size_t *num_domains
);
980 /* Flags for wbcLookupDomainController */
982 #define WBC_LOOKUP_DC_FORCE_REDISCOVERY 0x00000001
983 #define WBC_LOOKUP_DC_DS_REQUIRED 0x00000010
984 #define WBC_LOOKUP_DC_DS_PREFERRED 0x00000020
985 #define WBC_LOOKUP_DC_GC_SERVER_REQUIRED 0x00000040
986 #define WBC_LOOKUP_DC_PDC_REQUIRED 0x00000080
987 #define WBC_LOOKUP_DC_BACKGROUND_ONLY 0x00000100
988 #define WBC_LOOKUP_DC_IP_REQUIRED 0x00000200
989 #define WBC_LOOKUP_DC_KDC_REQUIRED 0x00000400
990 #define WBC_LOOKUP_DC_TIMESERV_REQUIRED 0x00000800
991 #define WBC_LOOKUP_DC_WRITABLE_REQUIRED 0x00001000
992 #define WBC_LOOKUP_DC_GOOD_TIMESERV_PREFERRED 0x00002000
993 #define WBC_LOOKUP_DC_AVOID_SELF 0x00004000
994 #define WBC_LOOKUP_DC_ONLY_LDAP_NEEDED 0x00008000
995 #define WBC_LOOKUP_DC_IS_FLAT_NAME 0x00010000
996 #define WBC_LOOKUP_DC_IS_DNS_NAME 0x00020000
997 #define WBC_LOOKUP_DC_TRY_NEXTCLOSEST_SITE 0x00040000
998 #define WBC_LOOKUP_DC_DS_6_REQUIRED 0x00080000
999 #define WBC_LOOKUP_DC_RETURN_DNS_NAME 0x40000000
1000 #define WBC_LOOKUP_DC_RETURN_FLAT_NAME 0x80000000
1003 * @brief Enumerate the domain trusts known by Winbind
1005 * @param domain Name of the domain to query for a DC
1006 * @param flags Bit flags used to control the domain location query
1007 * @param *dc_info Pointer to the returned domain controller information
1011 wbcErr
wbcLookupDomainController(const char *domain
,
1013 struct wbcDomainControllerInfo
**dc_info
);
1016 * @brief Get extended domain controller information
1018 * @param domain Name of the domain to query for a DC
1019 * @param guid Guid of the domain to query for a DC
1020 * @param site Site of the domain to query for a DC
1021 * @param flags Bit flags used to control the domain location query
1022 * @param *dc_info Pointer to the returned extended domain controller information
1026 wbcErr
wbcLookupDomainControllerEx(const char *domain
,
1027 struct wbcGuid
*guid
,
1030 struct wbcDomainControllerInfoEx
**dc_info
);
1032 /**********************************************************
1033 * Athenticate functions
1034 **********************************************************/
1037 * @brief Authenticate a username/password pair
1039 * @param username Name of user to authenticate
1040 * @param password Clear text password os user
1044 wbcErr
wbcAuthenticateUser(const char *username
,
1045 const char *password
);
1048 * @brief Authenticate with more detailed information
1050 * @param params Input parameters, WBC_AUTH_USER_LEVEL_HASH
1051 * is not supported yet
1052 * @param info Output details on WBC_ERR_SUCCESS
1053 * @param error Output details on WBC_ERR_AUTH_ERROR
1057 wbcErr
wbcAuthenticateUserEx(const struct wbcAuthUserParams
*params
,
1058 struct wbcAuthUserInfo
**info
,
1059 struct wbcAuthErrorInfo
**error
);
1062 * @brief Logon a User
1064 * @param[in] params Pointer to a wbcLogonUserParams structure
1065 * @param[out] info Pointer to a pointer to a wbcLogonUserInfo structure
1066 * @param[out] error Pointer to a pointer to a wbcAuthErrorInfo structure
1067 * @param[out] policy Pointer to a pointer to a wbcUserPasswordPolicyInfo structure
1071 wbcErr
wbcLogonUser(const struct wbcLogonUserParams
*params
,
1072 struct wbcLogonUserInfo
**info
,
1073 struct wbcAuthErrorInfo
**error
,
1074 struct wbcUserPasswordPolicyInfo
**policy
);
1077 * @brief Trigger a logoff notification to Winbind for a specific user
1079 * @param username Name of user to remove from Winbind's list of
1081 * @param uid Uid assigned to the username
1082 * @param ccfilename Absolute path to the Krb5 credentials cache to
1087 wbcErr
wbcLogoffUser(const char *username
,
1089 const char *ccfilename
);
1092 * @brief Trigger an extended logoff notification to Winbind for a specific user
1094 * @param params A wbcLogoffUserParams structure
1095 * @param error User output details on error
1099 wbcErr
wbcLogoffUserEx(const struct wbcLogoffUserParams
*params
,
1100 struct wbcAuthErrorInfo
**error
);
1103 * @brief Change a password for a user
1105 * @param username Name of user to authenticate
1106 * @param old_password Old clear text password of user
1107 * @param new_password New clear text password of user
1111 wbcErr
wbcChangeUserPassword(const char *username
,
1112 const char *old_password
,
1113 const char *new_password
);
1116 * @brief Change a password for a user with more detailed information upon
1119 * @param params Input parameters
1120 * @param error User output details on WBC_ERR_PWD_CHANGE_FAILED
1121 * @param reject_reason New password reject reason on WBC_ERR_PWD_CHANGE_FAILED
1122 * @param policy Password policy output details on WBC_ERR_PWD_CHANGE_FAILED
1126 wbcErr
wbcChangeUserPasswordEx(const struct wbcChangePasswordParams
*params
,
1127 struct wbcAuthErrorInfo
**error
,
1128 enum wbcPasswordChangeRejectReason
*reject_reason
,
1129 struct wbcUserPasswordPolicyInfo
**policy
);
1132 * @brief Authenticate a user with cached credentials
1134 * @param *params Pointer to a wbcCredentialCacheParams structure
1135 * @param **info Pointer to a pointer to a wbcCredentialCacheInfo structure
1136 * @param **error Pointer to a pointer to a wbcAuthErrorInfo structure
1140 wbcErr
wbcCredentialCache(struct wbcCredentialCacheParams
*params
,
1141 struct wbcCredentialCacheInfo
**info
,
1142 struct wbcAuthErrorInfo
**error
);
1144 /**********************************************************
1146 **********************************************************/
1149 * @brief Resolve a NetbiosName via WINS
1151 * @param name Name to resolve
1152 * @param *ip Pointer to the ip address string
1156 wbcErr
wbcResolveWinsByName(const char *name
, char **ip
);
1159 * @brief Resolve an IP address via WINS into a NetbiosName
1161 * @param ip The ip address string
1162 * @param *name Pointer to the name
1167 wbcErr
wbcResolveWinsByIP(const char *ip
, char **name
);
1169 /**********************************************************
1170 * Trusted domain functions
1171 **********************************************************/
1174 * @brief Trigger a verification of the trust credentials of a specific domain
1176 * @param *domain The name of the domain, only NULL for the default domain is
1177 * supported yet. Other values than NULL will result in
1178 * WBC_ERR_NOT_IMPLEMENTED.
1179 * @param error Output details on WBC_ERR_AUTH_ERROR
1183 wbcErr
wbcCheckTrustCredentials(const char *domain
,
1184 struct wbcAuthErrorInfo
**error
);
1186 /**********************************************************
1188 **********************************************************/
1191 * @brief Initialize a named blob and add to list of blobs
1193 * @param[in,out] num_blobs Pointer to the number of blobs
1194 * @param[in,out] blobs Pointer to an array of blobs
1195 * @param[in] name Name of the new named blob
1196 * @param[in] flags Flags of the new named blob
1197 * @param[in] data Blob data of new blob
1198 * @param[in] length Blob data length of new blob
1202 wbcErr
wbcAddNamedBlob(size_t *num_blobs
,
1203 struct wbcNamedBlob
**blobs
,
1209 #endif /* _WBCLIENT_H */