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
196 * @brief Auth User Parameters
199 struct wbcAuthUserParams
{
200 const char *account_name
;
201 const char *domain_name
;
202 const char *workstation_name
;
206 uint32_t parameter_control
;
208 enum wbcAuthUserLevel
{
209 WBC_AUTH_USER_LEVEL_PLAIN
= 1,
210 WBC_AUTH_USER_LEVEL_HASH
= 2,
211 WBC_AUTH_USER_LEVEL_RESPONSE
= 3
214 const char *plaintext
;
220 uint8_t challenge
[8];
230 * @brief Generic Blob
242 struct wbcNamedBlob
{
249 * @brief Logon User Parameters
252 struct wbcLogonUserParams
{
253 const char *username
;
254 const char *password
;
256 struct wbcNamedBlob
*blobs
;
260 * @brief ChangePassword Parameters
263 struct wbcChangePasswordParams
{
264 const char *account_name
;
265 const char *domain_name
;
269 enum wbcChangePasswordLevel
{
270 WBC_CHANGE_PASSWORD_LEVEL_PLAIN
= 1,
271 WBC_CHANGE_PASSWORD_LEVEL_RESPONSE
= 2
275 const char *plaintext
;
277 uint32_t old_nt_hash_enc_length
;
278 uint8_t *old_nt_hash_enc_data
;
279 uint32_t old_lm_hash_enc_length
;
280 uint8_t *old_lm_hash_enc_data
;
284 const char *plaintext
;
294 /* wbcAuthUserParams->parameter_control */
296 #define WBC_MSV1_0_CLEARTEXT_PASSWORD_ALLOWED 0x00000002
297 #define WBC_MSV1_0_UPDATE_LOGON_STATISTICS 0x00000004
298 #define WBC_MSV1_0_RETURN_USER_PARAMETERS 0x00000008
299 #define WBC_MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT 0x00000020
300 #define WBC_MSV1_0_RETURN_PROFILE_PATH 0x00000200
301 #define WBC_MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT 0x00000800
303 /* wbcAuthUserParams->flags */
305 #define WBC_AUTH_PARAM_FLAGS_INTERACTIVE_LOGON 0x00000001
308 * @brief Auth User Information
310 * Some of the strings are maybe NULL
313 struct wbcAuthUserInfo
{
317 char *user_principal
;
320 char *dns_domain_name
;
323 uint8_t user_session_key
[16];
324 uint8_t lm_session_key
[8];
326 uint16_t logon_count
;
327 uint16_t bad_password_count
;
330 uint64_t logoff_time
;
331 uint64_t kickoff_time
;
332 uint64_t pass_last_set_time
;
333 uint64_t pass_can_change_time
;
334 uint64_t pass_must_change_time
;
339 char *home_directory
;
343 * the 1st one is the account sid
344 * the 2nd one is the primary_group sid
345 * followed by the rest of the groups
348 struct wbcSidWithAttr
*sids
;
352 * @brief Logon User Information
354 * Some of the strings are maybe NULL
357 struct wbcLogonUserInfo
{
358 struct wbcAuthUserInfo
*info
;
360 struct wbcNamedBlob
*blobs
;
363 /* wbcAuthUserInfo->user_flags */
365 #define WBC_AUTH_USER_INFO_GUEST 0x00000001
366 #define WBC_AUTH_USER_INFO_NOENCRYPTION 0x00000002
367 #define WBC_AUTH_USER_INFO_CACHED_ACCOUNT 0x00000004
368 #define WBC_AUTH_USER_INFO_USED_LM_PASSWORD 0x00000008
369 #define WBC_AUTH_USER_INFO_EXTRA_SIDS 0x00000020
370 #define WBC_AUTH_USER_INFO_SUBAUTH_SESSION_KEY 0x00000040
371 #define WBC_AUTH_USER_INFO_SERVER_TRUST_ACCOUNT 0x00000080
372 #define WBC_AUTH_USER_INFO_NTLMV2_ENABLED 0x00000100
373 #define WBC_AUTH_USER_INFO_RESOURCE_GROUPS 0x00000200
374 #define WBC_AUTH_USER_INFO_PROFILE_PATH_RETURNED 0x00000400
375 #define WBC_AUTH_USER_INFO_GRACE_LOGON 0x01000000
377 /* wbcAuthUserInfo->acct_flags */
379 #define WBC_ACB_DISABLED 0x00000001 /* 1 User account disabled */
380 #define WBC_ACB_HOMDIRREQ 0x00000002 /* 1 Home directory required */
381 #define WBC_ACB_PWNOTREQ 0x00000004 /* 1 User password not required */
382 #define WBC_ACB_TEMPDUP 0x00000008 /* 1 Temporary duplicate account */
383 #define WBC_ACB_NORMAL 0x00000010 /* 1 Normal user account */
384 #define WBC_ACB_MNS 0x00000020 /* 1 MNS logon user account */
385 #define WBC_ACB_DOMTRUST 0x00000040 /* 1 Interdomain trust account */
386 #define WBC_ACB_WSTRUST 0x00000080 /* 1 Workstation trust account */
387 #define WBC_ACB_SVRTRUST 0x00000100 /* 1 Server trust account */
388 #define WBC_ACB_PWNOEXP 0x00000200 /* 1 User password does not expire */
389 #define WBC_ACB_AUTOLOCK 0x00000400 /* 1 Account auto locked */
390 #define WBC_ACB_ENC_TXT_PWD_ALLOWED 0x00000800 /* 1 Encryped text password is allowed */
391 #define WBC_ACB_SMARTCARD_REQUIRED 0x00001000 /* 1 Smart Card required */
392 #define WBC_ACB_TRUSTED_FOR_DELEGATION 0x00002000 /* 1 Trusted for Delegation */
393 #define WBC_ACB_NOT_DELEGATED 0x00004000 /* 1 Not delegated */
394 #define WBC_ACB_USE_DES_KEY_ONLY 0x00008000 /* 1 Use DES key only */
395 #define WBC_ACB_DONT_REQUIRE_PREAUTH 0x00010000 /* 1 Preauth not required */
396 #define WBC_ACB_PW_EXPIRED 0x00020000 /* 1 Password Expired */
397 #define WBC_ACB_NO_AUTH_DATA_REQD 0x00080000 /* 1 = No authorization data required */
399 struct wbcAuthErrorInfo
{
403 char *display_string
;
407 * @brief User Password Policy Information
410 /* wbcUserPasswordPolicyInfo->password_properties */
412 #define WBC_DOMAIN_PASSWORD_COMPLEX 0x00000001
413 #define WBC_DOMAIN_PASSWORD_NO_ANON_CHANGE 0x00000002
414 #define WBC_DOMAIN_PASSWORD_NO_CLEAR_CHANGE 0x00000004
415 #define WBC_DOMAIN_PASSWORD_LOCKOUT_ADMINS 0x00000008
416 #define WBC_DOMAIN_PASSWORD_STORE_CLEARTEXT 0x00000010
417 #define WBC_DOMAIN_REFUSE_PASSWORD_CHANGE 0x00000020
419 struct wbcUserPasswordPolicyInfo
{
420 uint32_t min_length_password
;
421 uint32_t password_history
;
422 uint32_t password_properties
;
424 uint64_t min_passwordage
;
428 * @brief Change Password Reject Reason
431 enum wbcPasswordChangeRejectReason
{
432 WBC_PWD_CHANGE_NO_ERROR
=0,
433 WBC_PWD_CHANGE_PASSWORD_TOO_SHORT
=1,
434 WBC_PWD_CHANGE_PWD_IN_HISTORY
=2,
435 WBC_PWD_CHANGE_USERNAME_IN_PASSWORD
=3,
436 WBC_PWD_CHANGE_FULLNAME_IN_PASSWORD
=4,
437 WBC_PWD_CHANGE_NOT_COMPLEX
=5,
438 WBC_PWD_CHANGE_MACHINE_NOT_DEFAULT
=6,
439 WBC_PWD_CHANGE_FAILED_BY_FILTER
=7,
440 WBC_PWD_CHANGE_PASSWORD_TOO_LONG
=8
443 /* Note: this defines exist for compatibility reasons with existing code */
444 #define WBC_PWD_CHANGE_REJECT_OTHER WBC_PWD_CHANGE_NO_ERROR
445 #define WBC_PWD_CHANGE_REJECT_TOO_SHORT WBC_PWD_CHANGE_PASSWORD_TOO_SHORT
446 #define WBC_PWD_CHANGE_REJECT_IN_HISTORY WBC_PWD_CHANGE_PWD_IN_HISTORY
447 #define WBC_PWD_CHANGE_REJECT_COMPLEXITY WBC_PWD_CHANGE_NOT_COMPLEX
450 * @brief Logoff User Parameters
453 struct wbcLogoffUserParams
{
454 const char *username
;
456 struct wbcNamedBlob
*blobs
;
459 /** @brief Credential cache log-on parameters
463 struct wbcCredentialCacheParams
{
464 const char *account_name
;
465 const char *domain_name
;
466 enum wbcCredentialCacheLevel
{
467 WBC_CREDENTIAL_CACHE_LEVEL_NTLMSSP
= 1
470 struct wbcNamedBlob
*blobs
;
474 /** @brief Info returned by credential cache auth
478 struct wbcCredentialCacheInfo
{
480 struct wbcNamedBlob
*blobs
;
484 * DomainControllerInfo struct
486 struct wbcDomainControllerInfo
{
491 * DomainControllerInfoEx struct
493 struct wbcDomainControllerInfoEx
{
495 const char *dc_address
;
496 uint16_t dc_address_type
;
497 struct wbcGuid
*domain_guid
;
498 const char *domain_name
;
499 const char *forest_name
;
501 const char *dc_site_name
;
502 const char *client_site_name
;
505 /**********************************************************
507 **********************************************************/
510 * @brief Free library allocated memory
512 * @param * Pointer to free
516 void wbcFreeMemory(void*);
520 * Utility functions for dealing with SIDs
524 * @brief Get a string representation of the SID type
526 * @param type type of the SID
528 * @return string representation of the SID type
530 const char* wbcSidTypeString(enum wbcSidType type
);
533 * @brief Convert a binary SID to a character string
535 * @param sid Binary Security Identifier
536 * @param **sid_string Resulting character string
540 wbcErr
wbcSidToString(const struct wbcDomainSid
*sid
,
544 * @brief Convert a character string to a binary SID
546 * @param *sid_string Character string in the form of S-...
547 * @param sid Resulting binary SID
551 wbcErr
wbcStringToSid(const char *sid_string
,
552 struct wbcDomainSid
*sid
);
555 * Utility functions for dealing with GUIDs
559 * @brief Convert a binary GUID to a character string
561 * @param guid Binary Guid
562 * @param **guid_string Resulting character string
566 wbcErr
wbcGuidToString(const struct wbcGuid
*guid
,
570 * @brief Convert a character string to a binary GUID
572 * @param *guid_string Character string
573 * @param guid Resulting binary GUID
577 wbcErr
wbcStringToGuid(const char *guid_string
,
578 struct wbcGuid
*guid
);
581 * @brief Ping winbindd to see if the daemon is running
585 wbcErr
wbcPing(void);
587 wbcErr
wbcLibraryDetails(struct wbcLibraryDetails
**details
);
589 wbcErr
wbcInterfaceDetails(struct wbcInterfaceDetails
**details
);
591 /**********************************************************
592 * Name/SID conversion
593 **********************************************************/
596 * @brief Convert a domain and name to SID
598 * @param dom_name Domain name (possibly "")
599 * @param name User or group name
600 * @param *sid Pointer to the resolved domain SID
601 * @param *name_type Pointer to the SID type
605 wbcErr
wbcLookupName(const char *dom_name
,
607 struct wbcDomainSid
*sid
,
608 enum wbcSidType
*name_type
);
611 * @brief Convert a SID to a domain and name
613 * @param *sid Pointer to the domain SID to be resolved
614 * @param domain Resolved Domain name (possibly "")
615 * @param name Resolved User or group name
616 * @param *name_type Pointer to the resolved SID type
620 wbcErr
wbcLookupSid(const struct wbcDomainSid
*sid
,
623 enum wbcSidType
*name_type
);
626 * @brief Translate a collection of RIDs within a domain to names
628 wbcErr
wbcLookupRids(struct wbcDomainSid
*dom_sid
,
631 const char **domain_name
,
633 enum wbcSidType
**types
);
636 * @brief Get the groups a user belongs to
638 wbcErr
wbcLookupUserSids(const struct wbcDomainSid
*user_sid
,
639 bool domain_groups_only
,
641 struct wbcDomainSid
**sids
);
644 * @brief Get alias membership for sids
646 wbcErr
wbcGetSidAliases(const struct wbcDomainSid
*dom_sid
,
647 struct wbcDomainSid
*sids
,
649 uint32_t **alias_rids
,
650 uint32_t *num_alias_rids
);
655 wbcErr
wbcListUsers(const char *domain_name
,
657 const char ***users
);
660 * @brief Lists Groups
662 wbcErr
wbcListGroups(const char *domain_name
,
663 uint32_t *num_groups
,
664 const char ***groups
);
666 wbcErr
wbcGetDisplayName(const struct wbcDomainSid
*sid
,
669 enum wbcSidType
*pname_type
);
671 /**********************************************************
672 * SID/uid/gid Mappings
673 **********************************************************/
676 * @brief Convert a Windows SID to a Unix uid, allocating an uid if needed
678 * @param *sid Pointer to the domain SID to be resolved
679 * @param *puid Pointer to the resolved uid_t value
684 wbcErr
wbcSidToUid(const struct wbcDomainSid
*sid
,
688 * @brief Convert a Windows SID to a Unix uid if there already is a mapping
690 * @param *sid Pointer to the domain SID to be resolved
691 * @param *puid Pointer to the resolved uid_t value
696 wbcErr
wbcQuerySidToUid(const struct wbcDomainSid
*sid
,
700 * @brief Convert a Unix uid to a Windows SID, allocating a SID if needed
702 * @param uid Unix uid to be resolved
703 * @param *sid Pointer to the resolved domain SID
708 wbcErr
wbcUidToSid(uid_t uid
,
709 struct wbcDomainSid
*sid
);
712 * @brief Convert a Unix uid to a Windows SID if there already is a mapping
714 * @param uid Unix uid to be resolved
715 * @param *sid Pointer to the resolved domain SID
720 wbcErr
wbcQueryUidToSid(uid_t uid
,
721 struct wbcDomainSid
*sid
);
724 * @brief Convert a Windows SID to a Unix gid, allocating a gid if needed
726 * @param *sid Pointer to the domain SID to be resolved
727 * @param *pgid Pointer to the resolved gid_t value
732 wbcErr
wbcSidToGid(const struct wbcDomainSid
*sid
,
736 * @brief Convert a Windows SID to a Unix gid if there already is a mapping
738 * @param *sid Pointer to the domain SID to be resolved
739 * @param *pgid Pointer to the resolved gid_t value
744 wbcErr
wbcQuerySidToGid(const struct wbcDomainSid
*sid
,
748 * @brief Convert a Unix gid to a Windows SID, allocating a SID if needed
750 * @param gid Unix gid to be resolved
751 * @param *sid Pointer to the resolved domain SID
756 wbcErr
wbcGidToSid(gid_t gid
,
757 struct wbcDomainSid
*sid
);
760 * @brief Convert a Unix gid to a Windows SID if there already is a mapping
762 * @param gid Unix gid to be resolved
763 * @param *sid Pointer to the resolved domain SID
768 wbcErr
wbcQueryGidToSid(gid_t gid
,
769 struct wbcDomainSid
*sid
);
772 * @brief Obtain a new uid from Winbind
774 * @param *puid *pointer to the allocated uid
778 wbcErr
wbcAllocateUid(uid_t
*puid
);
781 * @brief Obtain a new gid from Winbind
783 * @param *pgid Pointer to the allocated gid
787 wbcErr
wbcAllocateGid(gid_t
*pgid
);
789 /**********************************************************
790 * NSS Lookup User/Group details
791 **********************************************************/
794 * @brief Fill in a struct passwd* for a domain user based
797 * @param *name Username to lookup
798 * @param **pwd Pointer to resulting struct passwd* from the query.
802 wbcErr
wbcGetpwnam(const char *name
, struct passwd
**pwd
);
805 * @brief Fill in a struct passwd* for a domain user based
808 * @param uid Uid to lookup
809 * @param **pwd Pointer to resulting struct passwd* from the query.
813 wbcErr
wbcGetpwuid(uid_t uid
, struct passwd
**pwd
);
816 * @brief Fill in a struct passwd* for a domain user based
819 * @param sid Sid to lookup
820 * @param **pwd Pointer to resulting struct passwd* from the query.
824 wbcErr
wbcGetpwsid(struct wbcDomainSid
* sid
, struct passwd
**pwd
);
827 * @brief Fill in a struct passwd* for a domain user based
830 * @param *name Username to lookup
831 * @param **grp Pointer to resulting struct group* from the query.
835 wbcErr
wbcGetgrnam(const char *name
, struct group
**grp
);
838 * @brief Fill in a struct passwd* for a domain user based
841 * @param gid Uid to lookup
842 * @param **grp Pointer to resulting struct group* from the query.
846 wbcErr
wbcGetgrgid(gid_t gid
, struct group
**grp
);
849 * @brief Reset the passwd iterator
853 wbcErr
wbcSetpwent(void);
856 * @brief Close the passwd iterator
860 wbcErr
wbcEndpwent(void);
863 * @brief Return the next struct passwd* entry from the pwent iterator
865 * @param **pwd Pointer to resulting struct passwd* from the query.
869 wbcErr
wbcGetpwent(struct passwd
**pwd
);
872 * @brief Reset the group iterator
876 wbcErr
wbcSetgrent(void);
879 * @brief Close the group iterator
883 wbcErr
wbcEndgrent(void);
886 * @brief Return the next struct group* entry from the pwent iterator
888 * @param **grp Pointer to resulting struct group* from the query.
892 wbcErr
wbcGetgrent(struct group
**grp
);
895 * @brief Return the next struct group* entry from the pwent iterator
897 * This is similar to #wbcGetgrent, just that the member list is empty
899 * @param **grp Pointer to resulting struct group* from the query.
903 wbcErr
wbcGetgrlist(struct group
**grp
);
906 * @brief Return the unix group array belonging to the given user
908 * @param *account The given user name
909 * @param *num_groups Number of elements returned in the groups array
910 * @param **_groups Pointer to resulting gid_t array.
914 wbcErr
wbcGetGroups(const char *account
,
915 uint32_t *num_groups
,
919 /**********************************************************
920 * Lookup Domain information
921 **********************************************************/
924 * @brief Lookup the current status of a trusted domain
926 * @param domain The domain to query
928 * @param dinfo A pointer to store the returned domain_info struct.
932 wbcErr
wbcDomainInfo(const char *domain
,
933 struct wbcDomainInfo
**dinfo
);
936 * @brief Lookup the currently contacted DCs
938 * @param domain The domain to query
940 * @param num_dcs Number of DCs currently known
941 * @param dc_names Names of the currently known DCs
942 * @param dc_ips IP addresses of the currently known DCs
946 wbcErr
wbcDcInfo(const char *domain
, size_t *num_dcs
,
947 const char ***dc_names
, const char ***dc_ips
);
950 * @brief Enumerate the domain trusts known by Winbind
952 * @param **domains Pointer to the allocated domain list array
953 * @param *num_domains Pointer to number of domains returned
957 wbcErr
wbcListTrusts(struct wbcDomainInfo
**domains
,
958 size_t *num_domains
);
960 /* Flags for wbcLookupDomainController */
962 #define WBC_LOOKUP_DC_FORCE_REDISCOVERY 0x00000001
963 #define WBC_LOOKUP_DC_DS_REQUIRED 0x00000010
964 #define WBC_LOOKUP_DC_DS_PREFERRED 0x00000020
965 #define WBC_LOOKUP_DC_GC_SERVER_REQUIRED 0x00000040
966 #define WBC_LOOKUP_DC_PDC_REQUIRED 0x00000080
967 #define WBC_LOOKUP_DC_BACKGROUND_ONLY 0x00000100
968 #define WBC_LOOKUP_DC_IP_REQUIRED 0x00000200
969 #define WBC_LOOKUP_DC_KDC_REQUIRED 0x00000400
970 #define WBC_LOOKUP_DC_TIMESERV_REQUIRED 0x00000800
971 #define WBC_LOOKUP_DC_WRITABLE_REQUIRED 0x00001000
972 #define WBC_LOOKUP_DC_GOOD_TIMESERV_PREFERRED 0x00002000
973 #define WBC_LOOKUP_DC_AVOID_SELF 0x00004000
974 #define WBC_LOOKUP_DC_ONLY_LDAP_NEEDED 0x00008000
975 #define WBC_LOOKUP_DC_IS_FLAT_NAME 0x00010000
976 #define WBC_LOOKUP_DC_IS_DNS_NAME 0x00020000
977 #define WBC_LOOKUP_DC_TRY_NEXTCLOSEST_SITE 0x00040000
978 #define WBC_LOOKUP_DC_DS_6_REQUIRED 0x00080000
979 #define WBC_LOOKUP_DC_RETURN_DNS_NAME 0x40000000
980 #define WBC_LOOKUP_DC_RETURN_FLAT_NAME 0x80000000
983 * @brief Enumerate the domain trusts known by Winbind
985 * @param domain Name of the domain to query for a DC
986 * @param flags Bit flags used to control the domain location query
987 * @param *dc_info Pointer to the returned domain controller information
991 wbcErr
wbcLookupDomainController(const char *domain
,
993 struct wbcDomainControllerInfo
**dc_info
);
996 * @brief Get extended domain controller information
998 * @param domain Name of the domain to query for a DC
999 * @param guid Guid of the domain to query for a DC
1000 * @param site Site of the domain to query for a DC
1001 * @param flags Bit flags used to control the domain location query
1002 * @param *dc_info Pointer to the returned extended domain controller information
1006 wbcErr
wbcLookupDomainControllerEx(const char *domain
,
1007 struct wbcGuid
*guid
,
1010 struct wbcDomainControllerInfoEx
**dc_info
);
1012 /**********************************************************
1013 * Athenticate functions
1014 **********************************************************/
1017 * @brief Authenticate a username/password pair
1019 * @param username Name of user to authenticate
1020 * @param password Clear text password os user
1024 wbcErr
wbcAuthenticateUser(const char *username
,
1025 const char *password
);
1028 * @brief Authenticate with more detailed information
1030 * @param params Input parameters, WBC_AUTH_USER_LEVEL_HASH
1031 * is not supported yet
1032 * @param info Output details on WBC_ERR_SUCCESS
1033 * @param error Output details on WBC_ERR_AUTH_ERROR
1037 wbcErr
wbcAuthenticateUserEx(const struct wbcAuthUserParams
*params
,
1038 struct wbcAuthUserInfo
**info
,
1039 struct wbcAuthErrorInfo
**error
);
1042 * @brief Logon a User
1044 * @param[in] params Pointer to a wbcLogonUserParams structure
1045 * @param[out] info Pointer to a pointer to a wbcLogonUserInfo structure
1046 * @param[out] error Pointer to a pointer to a wbcAuthErrorInfo structure
1047 * @param[out] policy Pointer to a pointer to a wbcUserPasswordPolicyInfo structure
1051 wbcErr
wbcLogonUser(const struct wbcLogonUserParams
*params
,
1052 struct wbcLogonUserInfo
**info
,
1053 struct wbcAuthErrorInfo
**error
,
1054 struct wbcUserPasswordPolicyInfo
**policy
);
1057 * @brief Trigger a logoff notification to Winbind for a specific user
1059 * @param username Name of user to remove from Winbind's list of
1061 * @param uid Uid assigned to the username
1062 * @param ccfilename Absolute path to the Krb5 credentials cache to
1067 wbcErr
wbcLogoffUser(const char *username
,
1069 const char *ccfilename
);
1072 * @brief Trigger an extended logoff notification to Winbind for a specific user
1074 * @param params A wbcLogoffUserParams structure
1075 * @param error User output details on error
1079 wbcErr
wbcLogoffUserEx(const struct wbcLogoffUserParams
*params
,
1080 struct wbcAuthErrorInfo
**error
);
1083 * @brief Change a password for a user
1085 * @param username Name of user to authenticate
1086 * @param old_password Old clear text password of user
1087 * @param new_password New clear text password of user
1091 wbcErr
wbcChangeUserPassword(const char *username
,
1092 const char *old_password
,
1093 const char *new_password
);
1096 * @brief Change a password for a user with more detailed information upon
1099 * @param params Input parameters
1100 * @param error User output details on WBC_ERR_PWD_CHANGE_FAILED
1101 * @param reject_reason New password reject reason on WBC_ERR_PWD_CHANGE_FAILED
1102 * @param policy Password policy output details on WBC_ERR_PWD_CHANGE_FAILED
1106 wbcErr
wbcChangeUserPasswordEx(const struct wbcChangePasswordParams
*params
,
1107 struct wbcAuthErrorInfo
**error
,
1108 enum wbcPasswordChangeRejectReason
*reject_reason
,
1109 struct wbcUserPasswordPolicyInfo
**policy
);
1112 * @brief Authenticate a user with cached credentials
1114 * @param *params Pointer to a wbcCredentialCacheParams structure
1115 * @param **info Pointer to a pointer to a wbcCredentialCacheInfo structure
1116 * @param **error Pointer to a pointer to a wbcAuthErrorInfo structure
1120 wbcErr
wbcCredentialCache(struct wbcCredentialCacheParams
*params
,
1121 struct wbcCredentialCacheInfo
**info
,
1122 struct wbcAuthErrorInfo
**error
);
1125 * @brief Save a password with winbind for doing wbcCredentialCache() later
1127 * @param *user Username
1128 * @param *password Password
1132 wbcErr
wbcCredentialSave(const char *user
, const char *password
);
1134 /**********************************************************
1136 **********************************************************/
1139 * @brief Resolve a NetbiosName via WINS
1141 * @param name Name to resolve
1142 * @param *ip Pointer to the ip address string
1146 wbcErr
wbcResolveWinsByName(const char *name
, char **ip
);
1149 * @brief Resolve an IP address via WINS into a NetbiosName
1151 * @param ip The ip address string
1152 * @param *name Pointer to the name
1157 wbcErr
wbcResolveWinsByIP(const char *ip
, char **name
);
1159 /**********************************************************
1160 * Trusted domain functions
1161 **********************************************************/
1164 * @brief Trigger a verification of the trust credentials of a specific domain
1166 * @param *domain The name of the domain.
1167 * @param error Output details on WBC_ERR_AUTH_ERROR
1171 wbcErr
wbcCheckTrustCredentials(const char *domain
,
1172 struct wbcAuthErrorInfo
**error
);
1175 * @brief Trigger a change of the trust credentials for a specific domain
1177 * @param *domain The name of the domain.
1178 * @param error Output details on WBC_ERR_AUTH_ERROR
1182 wbcErr
wbcChangeTrustCredentials(const char *domain
,
1183 struct wbcAuthErrorInfo
**error
);
1186 * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost
1187 * version of wbcCheckTrustCredentials
1189 * @param *domain The name of the domain, only NULL for the default domain is
1190 * supported yet. Other values than NULL will result in
1191 * WBC_ERR_NOT_IMPLEMENTED.
1192 * @param error Output details on WBC_ERR_AUTH_ERROR
1196 wbcErr
wbcPingDc(const char *domain
, struct wbcAuthErrorInfo
**error
);
1198 /**********************************************************
1200 **********************************************************/
1203 * @brief Initialize a named blob and add to list of blobs
1205 * @param[in,out] num_blobs Pointer to the number of blobs
1206 * @param[in,out] blobs Pointer to an array of blobs
1207 * @param[in] name Name of the new named blob
1208 * @param[in] flags Flags of the new named blob
1209 * @param[in] data Blob data of new blob
1210 * @param[in] length Blob data length of new blob
1214 wbcErr
wbcAddNamedBlob(size_t *num_blobs
,
1215 struct wbcNamedBlob
**blobs
,
1221 #endif /* _WBCLIENT_H */