s4:ntvfs/ipc: fix protocol specific processing of pipe names
[Samba/gebeck_regimport.git] / nsswitch / libwbclient / wbclient.h
blob1dd387aef437936762afdbef32e78d1410c66fdc
1 /*
2 Unix SMB/CIFS implementation.
4 Winbind client API
6 Copyright (C) Gerald (Jerry) Carter 2007
7 Copyright (C) Volker Lendecke 2009
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 3 of the License, or (at your option) any later version.
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef _WBCLIENT_H
24 #define _WBCLIENT_H
26 #include <pwd.h>
27 #include <grp.h>
29 /* Define error types */
31 /**
32 * @brief Status codes returned from wbc functions
33 **/
35 enum _wbcErrType {
36 WBC_ERR_SUCCESS = 0, /**< Successful completion **/
37 WBC_ERR_NOT_IMPLEMENTED,/**< Function not implemented **/
38 WBC_ERR_UNKNOWN_FAILURE,/**< General failure **/
39 WBC_ERR_NO_MEMORY, /**< Memory allocation error **/
40 WBC_ERR_INVALID_SID, /**< Invalid SID format **/
41 WBC_ERR_INVALID_PARAM, /**< An Invalid parameter was supplied **/
42 WBC_ERR_WINBIND_NOT_AVAILABLE, /**< Winbind daemon is not available **/
43 WBC_ERR_DOMAIN_NOT_FOUND, /**< Domain is not trusted or cannot be found **/
44 WBC_ERR_INVALID_RESPONSE, /**< Winbind returned an invalid response **/
45 WBC_ERR_NSS_ERROR, /**< NSS_STATUS error **/
46 WBC_ERR_AUTH_ERROR, /**< Authentication failed **/
47 WBC_ERR_UNKNOWN_USER, /**< User account cannot be found */
48 WBC_ERR_UNKNOWN_GROUP, /**< Group account cannot be found */
49 WBC_ERR_PWD_CHANGE_FAILED /**< Password Change has failed */
52 typedef enum _wbcErrType wbcErr;
54 #define WBC_ERROR_IS_OK(x) ((x) == WBC_ERR_SUCCESS)
56 const char *wbcErrorString(wbcErr error);
58 /**
59 * @brief Some useful details about the wbclient library
61 * 0.1: Initial version
62 * 0.2: Added wbcRemoveUidMapping()
63 * Added wbcRemoveGidMapping()
64 * 0.3: Added wbcGetpwsid()
65 * Added wbcGetSidAliases()
66 * 0.4: Added wbcSidTypeString()
67 * 0.5: Added wbcChangeTrustCredentials()
68 * 0.6: Made struct wbcInterfaceDetails char* members non-const
69 * 0.7: Added wbcSidToStringBuf()
70 * 0.8: Added wbcSidsToUnixIds() and wbcLookupSids()
71 * 0.9: Added support for WBC_ID_TYPE_BOTH
72 **/
73 #define WBCLIENT_MAJOR_VERSION 0
74 #define WBCLIENT_MINOR_VERSION 9
75 #define WBCLIENT_VENDOR_VERSION "Samba libwbclient"
76 struct wbcLibraryDetails {
77 uint16_t major_version;
78 uint16_t minor_version;
79 const char *vendor_version;
82 /**
83 * @brief Some useful details about the running winbindd
85 **/
86 struct wbcInterfaceDetails {
87 uint32_t interface_version;
88 char *winbind_version;
89 char winbind_separator;
90 char *netbios_name;
91 char *netbios_domain;
92 char *dns_domain;
96 * Data types used by the Winbind Client API
99 #ifndef WBC_MAXSUBAUTHS
100 #define WBC_MAXSUBAUTHS 15 /* max sub authorities in a SID */
101 #endif
104 * @brief Windows Security Identifier
108 struct wbcDomainSid {
109 uint8_t sid_rev_num;
110 uint8_t num_auths;
111 uint8_t id_auth[6];
112 uint32_t sub_auths[WBC_MAXSUBAUTHS];
116 * @brief Security Identifier type
119 enum wbcSidType {
120 WBC_SID_NAME_USE_NONE=0,
121 WBC_SID_NAME_USER=1,
122 WBC_SID_NAME_DOM_GRP=2,
123 WBC_SID_NAME_DOMAIN=3,
124 WBC_SID_NAME_ALIAS=4,
125 WBC_SID_NAME_WKN_GRP=5,
126 WBC_SID_NAME_DELETED=6,
127 WBC_SID_NAME_INVALID=7,
128 WBC_SID_NAME_UNKNOWN=8,
129 WBC_SID_NAME_COMPUTER=9
133 * @brief Security Identifier with attributes
136 struct wbcSidWithAttr {
137 struct wbcDomainSid sid;
138 uint32_t attributes;
141 /* wbcSidWithAttr->attributes */
143 #define WBC_SID_ATTR_GROUP_MANDATORY 0x00000001
144 #define WBC_SID_ATTR_GROUP_ENABLED_BY_DEFAULT 0x00000002
145 #define WBC_SID_ATTR_GROUP_ENABLED 0x00000004
146 #define WBC_SID_ATTR_GROUP_OWNER 0x00000008
147 #define WBC_SID_ATTR_GROUP_USEFOR_DENY_ONLY 0x00000010
148 #define WBC_SID_ATTR_GROUP_RESOURCE 0x20000000
149 #define WBC_SID_ATTR_GROUP_LOGON_ID 0xC0000000
152 * @brief Windows GUID
156 struct wbcGuid {
157 uint32_t time_low;
158 uint16_t time_mid;
159 uint16_t time_hi_and_version;
160 uint8_t clock_seq[2];
161 uint8_t node[6];
165 * @brief Domain Information
168 struct wbcDomainInfo {
169 char *short_name;
170 char *dns_name;
171 struct wbcDomainSid sid;
172 uint32_t domain_flags;
173 uint32_t trust_flags;
174 uint32_t trust_type;
177 /* wbcDomainInfo->domain_flags */
179 #define WBC_DOMINFO_DOMAIN_UNKNOWN 0x00000000
180 #define WBC_DOMINFO_DOMAIN_NATIVE 0x00000001
181 #define WBC_DOMINFO_DOMAIN_AD 0x00000002
182 #define WBC_DOMINFO_DOMAIN_PRIMARY 0x00000004
183 #define WBC_DOMINFO_DOMAIN_OFFLINE 0x00000008
185 /* wbcDomainInfo->trust_flags */
187 #define WBC_DOMINFO_TRUST_TRANSITIVE 0x00000001
188 #define WBC_DOMINFO_TRUST_INCOMING 0x00000002
189 #define WBC_DOMINFO_TRUST_OUTGOING 0x00000004
191 /* wbcDomainInfo->trust_type */
193 #define WBC_DOMINFO_TRUSTTYPE_NONE 0x00000000
194 #define WBC_DOMINFO_TRUSTTYPE_FOREST 0x00000001
195 #define WBC_DOMINFO_TRUSTTYPE_IN_FOREST 0x00000002
196 #define WBC_DOMINFO_TRUSTTYPE_EXTERNAL 0x00000003
199 * @brief Auth User Parameters
202 struct wbcAuthUserParams {
203 const char *account_name;
204 const char *domain_name;
205 const char *workstation_name;
207 uint32_t flags;
209 uint32_t parameter_control;
211 enum wbcAuthUserLevel {
212 WBC_AUTH_USER_LEVEL_PLAIN = 1,
213 WBC_AUTH_USER_LEVEL_HASH = 2,
214 WBC_AUTH_USER_LEVEL_RESPONSE = 3
215 } level;
216 union {
217 const char *plaintext;
218 struct {
219 uint8_t nt_hash[16];
220 uint8_t lm_hash[16];
221 } hash;
222 struct {
223 uint8_t challenge[8];
224 uint32_t nt_length;
225 uint8_t *nt_data;
226 uint32_t lm_length;
227 uint8_t *lm_data;
228 } response;
229 } password;
233 * @brief Generic Blob
236 struct wbcBlob {
237 uint8_t *data;
238 size_t length;
242 * @brief Named Blob
245 struct wbcNamedBlob {
246 const char *name;
247 uint32_t flags;
248 struct wbcBlob blob;
252 * @brief Logon User Parameters
255 struct wbcLogonUserParams {
256 const char *username;
257 const char *password;
258 size_t num_blobs;
259 struct wbcNamedBlob *blobs;
263 * @brief ChangePassword Parameters
266 struct wbcChangePasswordParams {
267 const char *account_name;
268 const char *domain_name;
270 uint32_t flags;
272 enum wbcChangePasswordLevel {
273 WBC_CHANGE_PASSWORD_LEVEL_PLAIN = 1,
274 WBC_CHANGE_PASSWORD_LEVEL_RESPONSE = 2
275 } level;
277 union {
278 const char *plaintext;
279 struct {
280 uint32_t old_nt_hash_enc_length;
281 uint8_t *old_nt_hash_enc_data;
282 uint32_t old_lm_hash_enc_length;
283 uint8_t *old_lm_hash_enc_data;
284 } response;
285 } old_password;
286 union {
287 const char *plaintext;
288 struct {
289 uint32_t nt_length;
290 uint8_t *nt_data;
291 uint32_t lm_length;
292 uint8_t *lm_data;
293 } response;
294 } new_password;
297 /* wbcAuthUserParams->parameter_control */
299 #define WBC_MSV1_0_CLEARTEXT_PASSWORD_ALLOWED 0x00000002
300 #define WBC_MSV1_0_UPDATE_LOGON_STATISTICS 0x00000004
301 #define WBC_MSV1_0_RETURN_USER_PARAMETERS 0x00000008
302 #define WBC_MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT 0x00000020
303 #define WBC_MSV1_0_RETURN_PROFILE_PATH 0x00000200
304 #define WBC_MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT 0x00000800
306 /* wbcAuthUserParams->flags */
308 #define WBC_AUTH_PARAM_FLAGS_INTERACTIVE_LOGON 0x00000001
311 * @brief Auth User Information
313 * Some of the strings are maybe NULL
316 struct wbcAuthUserInfo {
317 uint32_t user_flags;
319 char *account_name;
320 char *user_principal;
321 char *full_name;
322 char *domain_name;
323 char *dns_domain_name;
325 uint32_t acct_flags;
326 uint8_t user_session_key[16];
327 uint8_t lm_session_key[8];
329 uint16_t logon_count;
330 uint16_t bad_password_count;
332 uint64_t logon_time;
333 uint64_t logoff_time;
334 uint64_t kickoff_time;
335 uint64_t pass_last_set_time;
336 uint64_t pass_can_change_time;
337 uint64_t pass_must_change_time;
339 char *logon_server;
340 char *logon_script;
341 char *profile_path;
342 char *home_directory;
343 char *home_drive;
346 * the 1st one is the account sid
347 * the 2nd one is the primary_group sid
348 * followed by the rest of the groups
350 uint32_t num_sids;
351 struct wbcSidWithAttr *sids;
355 * @brief Logon User Information
357 * Some of the strings are maybe NULL
360 struct wbcLogonUserInfo {
361 struct wbcAuthUserInfo *info;
362 size_t num_blobs;
363 struct wbcNamedBlob *blobs;
366 /* wbcAuthUserInfo->user_flags */
368 #define WBC_AUTH_USER_INFO_GUEST 0x00000001
369 #define WBC_AUTH_USER_INFO_NOENCRYPTION 0x00000002
370 #define WBC_AUTH_USER_INFO_CACHED_ACCOUNT 0x00000004
371 #define WBC_AUTH_USER_INFO_USED_LM_PASSWORD 0x00000008
372 #define WBC_AUTH_USER_INFO_EXTRA_SIDS 0x00000020
373 #define WBC_AUTH_USER_INFO_SUBAUTH_SESSION_KEY 0x00000040
374 #define WBC_AUTH_USER_INFO_SERVER_TRUST_ACCOUNT 0x00000080
375 #define WBC_AUTH_USER_INFO_NTLMV2_ENABLED 0x00000100
376 #define WBC_AUTH_USER_INFO_RESOURCE_GROUPS 0x00000200
377 #define WBC_AUTH_USER_INFO_PROFILE_PATH_RETURNED 0x00000400
378 #define WBC_AUTH_USER_INFO_GRACE_LOGON 0x01000000
380 /* wbcAuthUserInfo->acct_flags */
382 #define WBC_ACB_DISABLED 0x00000001 /* 1 User account disabled */
383 #define WBC_ACB_HOMDIRREQ 0x00000002 /* 1 Home directory required */
384 #define WBC_ACB_PWNOTREQ 0x00000004 /* 1 User password not required */
385 #define WBC_ACB_TEMPDUP 0x00000008 /* 1 Temporary duplicate account */
386 #define WBC_ACB_NORMAL 0x00000010 /* 1 Normal user account */
387 #define WBC_ACB_MNS 0x00000020 /* 1 MNS logon user account */
388 #define WBC_ACB_DOMTRUST 0x00000040 /* 1 Interdomain trust account */
389 #define WBC_ACB_WSTRUST 0x00000080 /* 1 Workstation trust account */
390 #define WBC_ACB_SVRTRUST 0x00000100 /* 1 Server trust account */
391 #define WBC_ACB_PWNOEXP 0x00000200 /* 1 User password does not expire */
392 #define WBC_ACB_AUTOLOCK 0x00000400 /* 1 Account auto locked */
393 #define WBC_ACB_ENC_TXT_PWD_ALLOWED 0x00000800 /* 1 Encryped text password is allowed */
394 #define WBC_ACB_SMARTCARD_REQUIRED 0x00001000 /* 1 Smart Card required */
395 #define WBC_ACB_TRUSTED_FOR_DELEGATION 0x00002000 /* 1 Trusted for Delegation */
396 #define WBC_ACB_NOT_DELEGATED 0x00004000 /* 1 Not delegated */
397 #define WBC_ACB_USE_DES_KEY_ONLY 0x00008000 /* 1 Use DES key only */
398 #define WBC_ACB_DONT_REQUIRE_PREAUTH 0x00010000 /* 1 Preauth not required */
399 #define WBC_ACB_PW_EXPIRED 0x00020000 /* 1 Password Expired */
400 #define WBC_ACB_NO_AUTH_DATA_REQD 0x00080000 /* 1 = No authorization data required */
402 struct wbcAuthErrorInfo {
403 uint32_t nt_status;
404 char *nt_string;
405 int32_t pam_error;
406 char *display_string;
410 * @brief User Password Policy Information
413 /* wbcUserPasswordPolicyInfo->password_properties */
415 #define WBC_DOMAIN_PASSWORD_COMPLEX 0x00000001
416 #define WBC_DOMAIN_PASSWORD_NO_ANON_CHANGE 0x00000002
417 #define WBC_DOMAIN_PASSWORD_NO_CLEAR_CHANGE 0x00000004
418 #define WBC_DOMAIN_PASSWORD_LOCKOUT_ADMINS 0x00000008
419 #define WBC_DOMAIN_PASSWORD_STORE_CLEARTEXT 0x00000010
420 #define WBC_DOMAIN_REFUSE_PASSWORD_CHANGE 0x00000020
422 struct wbcUserPasswordPolicyInfo {
423 uint32_t min_length_password;
424 uint32_t password_history;
425 uint32_t password_properties;
426 uint64_t expire;
427 uint64_t min_passwordage;
431 * @brief Change Password Reject Reason
434 enum wbcPasswordChangeRejectReason {
435 WBC_PWD_CHANGE_NO_ERROR=0,
436 WBC_PWD_CHANGE_PASSWORD_TOO_SHORT=1,
437 WBC_PWD_CHANGE_PWD_IN_HISTORY=2,
438 WBC_PWD_CHANGE_USERNAME_IN_PASSWORD=3,
439 WBC_PWD_CHANGE_FULLNAME_IN_PASSWORD=4,
440 WBC_PWD_CHANGE_NOT_COMPLEX=5,
441 WBC_PWD_CHANGE_MACHINE_NOT_DEFAULT=6,
442 WBC_PWD_CHANGE_FAILED_BY_FILTER=7,
443 WBC_PWD_CHANGE_PASSWORD_TOO_LONG=8
446 /* Note: this defines exist for compatibility reasons with existing code */
447 #define WBC_PWD_CHANGE_REJECT_OTHER WBC_PWD_CHANGE_NO_ERROR
448 #define WBC_PWD_CHANGE_REJECT_TOO_SHORT WBC_PWD_CHANGE_PASSWORD_TOO_SHORT
449 #define WBC_PWD_CHANGE_REJECT_IN_HISTORY WBC_PWD_CHANGE_PWD_IN_HISTORY
450 #define WBC_PWD_CHANGE_REJECT_COMPLEXITY WBC_PWD_CHANGE_NOT_COMPLEX
453 * @brief Logoff User Parameters
456 struct wbcLogoffUserParams {
457 const char *username;
458 size_t num_blobs;
459 struct wbcNamedBlob *blobs;
462 /** @brief Credential cache log-on parameters
466 struct wbcCredentialCacheParams {
467 const char *account_name;
468 const char *domain_name;
469 enum wbcCredentialCacheLevel {
470 WBC_CREDENTIAL_CACHE_LEVEL_NTLMSSP = 1
471 } level;
472 size_t num_blobs;
473 struct wbcNamedBlob *blobs;
477 /** @brief Info returned by credential cache auth
481 struct wbcCredentialCacheInfo {
482 size_t num_blobs;
483 struct wbcNamedBlob *blobs;
487 * DomainControllerInfo struct
489 struct wbcDomainControllerInfo {
490 char *dc_name;
494 * DomainControllerInfoEx struct
496 struct wbcDomainControllerInfoEx {
497 const char *dc_unc;
498 const char *dc_address;
499 uint16_t dc_address_type;
500 struct wbcGuid *domain_guid;
501 const char *domain_name;
502 const char *forest_name;
503 uint32_t dc_flags;
504 const char *dc_site_name;
505 const char *client_site_name;
508 /**********************************************************
509 * Memory Management
510 **********************************************************/
513 * @brief Free library allocated memory
515 * @param * Pointer to free
517 * @return void
519 void wbcFreeMemory(void*);
523 * Utility functions for dealing with SIDs
527 * @brief Get a string representation of the SID type
529 * @param type type of the SID
531 * @return string representation of the SID type
533 const char* wbcSidTypeString(enum wbcSidType type);
535 #define WBC_SID_STRING_BUFLEN (15*11+25)
538 * @brief Print a sid into a buffer
540 * @param sid Binary Security Identifier
541 * @param buf Target buffer
542 * @param buflen Target buffer length
544 * @return Resulting string length.
546 int wbcSidToStringBuf(const struct wbcDomainSid *sid, char *buf, int buflen);
549 * @brief Convert a binary SID to a character string
551 * @param sid Binary Security Identifier
552 * @param **sid_string Resulting character string
554 * @return #wbcErr
556 wbcErr wbcSidToString(const struct wbcDomainSid *sid,
557 char **sid_string);
560 * @brief Convert a character string to a binary SID
562 * @param *sid_string Character string in the form of S-...
563 * @param sid Resulting binary SID
565 * @return #wbcErr
567 wbcErr wbcStringToSid(const char *sid_string,
568 struct wbcDomainSid *sid);
571 * Utility functions for dealing with GUIDs
575 * @brief Convert a binary GUID to a character string
577 * @param guid Binary Guid
578 * @param **guid_string Resulting character string
580 * @return #wbcErr
582 wbcErr wbcGuidToString(const struct wbcGuid *guid,
583 char **guid_string);
586 * @brief Convert a character string to a binary GUID
588 * @param *guid_string Character string
589 * @param guid Resulting binary GUID
591 * @return #wbcErr
593 wbcErr wbcStringToGuid(const char *guid_string,
594 struct wbcGuid *guid);
597 * @brief Ping winbindd to see if the daemon is running
599 * @return #wbcErr
601 wbcErr wbcPing(void);
603 wbcErr wbcLibraryDetails(struct wbcLibraryDetails **details);
605 wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **details);
607 /**********************************************************
608 * Name/SID conversion
609 **********************************************************/
612 * @brief Convert a domain and name to SID
614 * @param dom_name Domain name (possibly "")
615 * @param name User or group name
616 * @param *sid Pointer to the resolved domain SID
617 * @param *name_type Pointer to the SID type
619 * @return #wbcErr
621 wbcErr wbcLookupName(const char *dom_name,
622 const char *name,
623 struct wbcDomainSid *sid,
624 enum wbcSidType *name_type);
627 * @brief Convert a SID to a domain and name
629 * @param *sid Pointer to the domain SID to be resolved
630 * @param domain Resolved Domain name (possibly "")
631 * @param name Resolved User or group name
632 * @param *name_type Pointer to the resolved SID type
634 * @return #wbcErr
636 wbcErr wbcLookupSid(const struct wbcDomainSid *sid,
637 char **domain,
638 char **name,
639 enum wbcSidType *name_type);
641 struct wbcTranslatedName {
642 enum wbcSidType type;
643 char *name;
644 int domain_index;
647 wbcErr wbcLookupSids(const struct wbcDomainSid *sids, int num_sids,
648 struct wbcDomainInfo **domains, int *num_domains,
649 struct wbcTranslatedName **names);
652 * @brief Translate a collection of RIDs within a domain to names
654 wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
655 int num_rids,
656 uint32_t *rids,
657 const char **domain_name,
658 const char ***names,
659 enum wbcSidType **types);
662 * @brief Get the groups a user belongs to
664 wbcErr wbcLookupUserSids(const struct wbcDomainSid *user_sid,
665 bool domain_groups_only,
666 uint32_t *num_sids,
667 struct wbcDomainSid **sids);
670 * @brief Get alias membership for sids
672 wbcErr wbcGetSidAliases(const struct wbcDomainSid *dom_sid,
673 struct wbcDomainSid *sids,
674 uint32_t num_sids,
675 uint32_t **alias_rids,
676 uint32_t *num_alias_rids);
679 * @brief Lists Users
681 wbcErr wbcListUsers(const char *domain_name,
682 uint32_t *num_users,
683 const char ***users);
686 * @brief Lists Groups
688 wbcErr wbcListGroups(const char *domain_name,
689 uint32_t *num_groups,
690 const char ***groups);
692 wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid,
693 char **pdomain,
694 char **pfullname,
695 enum wbcSidType *pname_type);
697 /**********************************************************
698 * SID/uid/gid Mappings
699 **********************************************************/
702 * @brief Convert a Windows SID to a Unix uid, allocating an uid if needed
704 * @param *sid Pointer to the domain SID to be resolved
705 * @param *puid Pointer to the resolved uid_t value
707 * @return #wbcErr
710 wbcErr wbcSidToUid(const struct wbcDomainSid *sid,
711 uid_t *puid);
714 * @brief Convert a Windows SID to a Unix uid if there already is a mapping
716 * @param *sid Pointer to the domain SID to be resolved
717 * @param *puid Pointer to the resolved uid_t value
719 * @return #wbcErr
722 wbcErr wbcQuerySidToUid(const struct wbcDomainSid *sid,
723 uid_t *puid);
726 * @brief Convert a Unix uid to a Windows SID, allocating a SID if needed
728 * @param uid Unix uid to be resolved
729 * @param *sid Pointer to the resolved domain SID
731 * @return #wbcErr
734 wbcErr wbcUidToSid(uid_t uid,
735 struct wbcDomainSid *sid);
738 * @brief Convert a Unix uid to a Windows SID if there already is a mapping
740 * @param uid Unix uid to be resolved
741 * @param *sid Pointer to the resolved domain SID
743 * @return #wbcErr
746 wbcErr wbcQueryUidToSid(uid_t uid,
747 struct wbcDomainSid *sid);
750 * @brief Convert a Windows SID to a Unix gid, allocating a gid if needed
752 * @param *sid Pointer to the domain SID to be resolved
753 * @param *pgid Pointer to the resolved gid_t value
755 * @return #wbcErr
758 wbcErr wbcSidToGid(const struct wbcDomainSid *sid,
759 gid_t *pgid);
762 * @brief Convert a Windows SID to a Unix gid if there already is a mapping
764 * @param *sid Pointer to the domain SID to be resolved
765 * @param *pgid Pointer to the resolved gid_t value
767 * @return #wbcErr
770 wbcErr wbcQuerySidToGid(const struct wbcDomainSid *sid,
771 gid_t *pgid);
774 * @brief Convert a Unix gid to a Windows SID, allocating a SID if needed
776 * @param gid Unix gid to be resolved
777 * @param *sid Pointer to the resolved domain SID
779 * @return #wbcErr
782 wbcErr wbcGidToSid(gid_t gid,
783 struct wbcDomainSid *sid);
786 * @brief Convert a Unix gid to a Windows SID if there already is a mapping
788 * @param gid Unix gid to be resolved
789 * @param *sid Pointer to the resolved domain SID
791 * @return #wbcErr
794 wbcErr wbcQueryGidToSid(gid_t gid,
795 struct wbcDomainSid *sid);
797 enum wbcIdType {
798 WBC_ID_TYPE_NOT_SPECIFIED,
799 WBC_ID_TYPE_UID,
800 WBC_ID_TYPE_GID,
801 WBC_ID_TYPE_BOTH
804 union wbcUnixIdContainer {
805 uid_t uid;
806 gid_t gid;
809 struct wbcUnixId {
810 enum wbcIdType type;
811 union wbcUnixIdContainer id;
815 * @brief Convert a list of sids to unix ids
817 * @param sids Pointer to an array of SIDs to convert
818 * @param num_sids Number of SIDs
819 * @param ids Preallocated output array for translated IDs
821 * @return #wbcErr
824 wbcErr wbcSidsToUnixIds(const struct wbcDomainSid *sids, uint32_t num_sids,
825 struct wbcUnixId *ids);
828 * @brief Obtain a new uid from Winbind
830 * @param *puid *pointer to the allocated uid
832 * @return #wbcErr
834 wbcErr wbcAllocateUid(uid_t *puid);
837 * @brief Obtain a new gid from Winbind
839 * @param *pgid Pointer to the allocated gid
841 * @return #wbcErr
843 wbcErr wbcAllocateGid(gid_t *pgid);
846 * @brief Set an user id mapping
848 * @param uid Uid of the desired mapping.
849 * @param *sid Pointer to the sid of the diresired mapping.
851 * @return #wbcErr
853 * @deprecated This method is not impemented any more and should
854 * be removed in the next major version change.
856 wbcErr wbcSetUidMapping(uid_t uid, const struct wbcDomainSid *sid);
859 * @brief Set a group id mapping
861 * @param gid Gid of the desired mapping.
862 * @param *sid Pointer to the sid of the diresired mapping.
864 * @return #wbcErr
866 * @deprecated This method is not impemented any more and should
867 * be removed in the next major version change.
869 wbcErr wbcSetGidMapping(gid_t gid, const struct wbcDomainSid *sid);
872 * @brief Remove a user id mapping
874 * @param uid Uid of the mapping to remove.
875 * @param *sid Pointer to the sid of the mapping to remove.
877 * @return #wbcErr
879 * @deprecated This method is not impemented any more and should
880 * be removed in the next major version change.
882 wbcErr wbcRemoveUidMapping(uid_t uid, const struct wbcDomainSid *sid);
885 * @brief Remove a group id mapping
887 * @param gid Gid of the mapping to remove.
888 * @param *sid Pointer to the sid of the mapping to remove.
890 * @return #wbcErr
892 * @deprecated This method is not impemented any more and should
893 * be removed in the next major version change.
895 wbcErr wbcRemoveGidMapping(gid_t gid, const struct wbcDomainSid *sid);
898 * @brief Set the highwater mark for allocated uids.
900 * @param uid_hwm The new uid highwater mark value
902 * @return #wbcErr
904 * @deprecated This method is not impemented any more and should
905 * be removed in the next major version change.
907 wbcErr wbcSetUidHwm(uid_t uid_hwm);
910 * @brief Set the highwater mark for allocated gids.
912 * @param gid_hwm The new gid highwater mark value
914 * @return #wbcErr
916 * @deprecated This method is not impemented any more and should
917 * be removed in the next major version change.
919 wbcErr wbcSetGidHwm(gid_t gid_hwm);
921 /**********************************************************
922 * NSS Lookup User/Group details
923 **********************************************************/
926 * @brief Fill in a struct passwd* for a domain user based
927 * on username
929 * @param *name Username to lookup
930 * @param **pwd Pointer to resulting struct passwd* from the query.
932 * @return #wbcErr
934 wbcErr wbcGetpwnam(const char *name, struct passwd **pwd);
937 * @brief Fill in a struct passwd* for a domain user based
938 * on uid
940 * @param uid Uid to lookup
941 * @param **pwd Pointer to resulting struct passwd* from the query.
943 * @return #wbcErr
945 wbcErr wbcGetpwuid(uid_t uid, struct passwd **pwd);
948 * @brief Fill in a struct passwd* for a domain user based
949 * on sid
951 * @param sid Sid to lookup
952 * @param **pwd Pointer to resulting struct passwd* from the query.
954 * @return #wbcErr
956 wbcErr wbcGetpwsid(struct wbcDomainSid * sid, struct passwd **pwd);
959 * @brief Fill in a struct passwd* for a domain user based
960 * on username
962 * @param *name Username to lookup
963 * @param **grp Pointer to resulting struct group* from the query.
965 * @return #wbcErr
967 wbcErr wbcGetgrnam(const char *name, struct group **grp);
970 * @brief Fill in a struct passwd* for a domain user based
971 * on uid
973 * @param gid Uid to lookup
974 * @param **grp Pointer to resulting struct group* from the query.
976 * @return #wbcErr
978 wbcErr wbcGetgrgid(gid_t gid, struct group **grp);
981 * @brief Reset the passwd iterator
983 * @return #wbcErr
985 wbcErr wbcSetpwent(void);
988 * @brief Close the passwd iterator
990 * @return #wbcErr
992 wbcErr wbcEndpwent(void);
995 * @brief Return the next struct passwd* entry from the pwent iterator
997 * @param **pwd Pointer to resulting struct passwd* from the query.
999 * @return #wbcErr
1001 wbcErr wbcGetpwent(struct passwd **pwd);
1004 * @brief Reset the group iterator
1006 * @return #wbcErr
1008 wbcErr wbcSetgrent(void);
1011 * @brief Close the group iterator
1013 * @return #wbcErr
1015 wbcErr wbcEndgrent(void);
1018 * @brief Return the next struct group* entry from the pwent iterator
1020 * @param **grp Pointer to resulting struct group* from the query.
1022 * @return #wbcErr
1024 wbcErr wbcGetgrent(struct group **grp);
1027 * @brief Return the next struct group* entry from the pwent iterator
1029 * This is similar to #wbcGetgrent, just that the member list is empty
1031 * @param **grp Pointer to resulting struct group* from the query.
1033 * @return #wbcErr
1035 wbcErr wbcGetgrlist(struct group **grp);
1038 * @brief Return the unix group array belonging to the given user
1040 * @param *account The given user name
1041 * @param *num_groups Number of elements returned in the groups array
1042 * @param **_groups Pointer to resulting gid_t array.
1044 * @return #wbcErr
1046 wbcErr wbcGetGroups(const char *account,
1047 uint32_t *num_groups,
1048 gid_t **_groups);
1051 /**********************************************************
1052 * Lookup Domain information
1053 **********************************************************/
1056 * @brief Lookup the current status of a trusted domain
1058 * @param domain The domain to query
1060 * @param dinfo A pointer to store the returned domain_info struct.
1062 * @return #wbcErr
1064 wbcErr wbcDomainInfo(const char *domain,
1065 struct wbcDomainInfo **dinfo);
1068 * @brief Lookup the currently contacted DCs
1070 * @param domain The domain to query
1072 * @param num_dcs Number of DCs currently known
1073 * @param dc_names Names of the currently known DCs
1074 * @param dc_ips IP addresses of the currently known DCs
1076 * @return #wbcErr
1078 wbcErr wbcDcInfo(const char *domain, size_t *num_dcs,
1079 const char ***dc_names, const char ***dc_ips);
1082 * @brief Enumerate the domain trusts known by Winbind
1084 * @param **domains Pointer to the allocated domain list array
1085 * @param *num_domains Pointer to number of domains returned
1087 * @return #wbcErr
1089 wbcErr wbcListTrusts(struct wbcDomainInfo **domains,
1090 size_t *num_domains);
1092 /* Flags for wbcLookupDomainController */
1094 #define WBC_LOOKUP_DC_FORCE_REDISCOVERY 0x00000001
1095 #define WBC_LOOKUP_DC_DS_REQUIRED 0x00000010
1096 #define WBC_LOOKUP_DC_DS_PREFERRED 0x00000020
1097 #define WBC_LOOKUP_DC_GC_SERVER_REQUIRED 0x00000040
1098 #define WBC_LOOKUP_DC_PDC_REQUIRED 0x00000080
1099 #define WBC_LOOKUP_DC_BACKGROUND_ONLY 0x00000100
1100 #define WBC_LOOKUP_DC_IP_REQUIRED 0x00000200
1101 #define WBC_LOOKUP_DC_KDC_REQUIRED 0x00000400
1102 #define WBC_LOOKUP_DC_TIMESERV_REQUIRED 0x00000800
1103 #define WBC_LOOKUP_DC_WRITABLE_REQUIRED 0x00001000
1104 #define WBC_LOOKUP_DC_GOOD_TIMESERV_PREFERRED 0x00002000
1105 #define WBC_LOOKUP_DC_AVOID_SELF 0x00004000
1106 #define WBC_LOOKUP_DC_ONLY_LDAP_NEEDED 0x00008000
1107 #define WBC_LOOKUP_DC_IS_FLAT_NAME 0x00010000
1108 #define WBC_LOOKUP_DC_IS_DNS_NAME 0x00020000
1109 #define WBC_LOOKUP_DC_TRY_NEXTCLOSEST_SITE 0x00040000
1110 #define WBC_LOOKUP_DC_DS_6_REQUIRED 0x00080000
1111 #define WBC_LOOKUP_DC_RETURN_DNS_NAME 0x40000000
1112 #define WBC_LOOKUP_DC_RETURN_FLAT_NAME 0x80000000
1115 * @brief Enumerate the domain trusts known by Winbind
1117 * @param domain Name of the domain to query for a DC
1118 * @param flags Bit flags used to control the domain location query
1119 * @param *dc_info Pointer to the returned domain controller information
1121 * @return #wbcErr
1123 wbcErr wbcLookupDomainController(const char *domain,
1124 uint32_t flags,
1125 struct wbcDomainControllerInfo **dc_info);
1128 * @brief Get extended domain controller information
1130 * @param domain Name of the domain to query for a DC
1131 * @param guid Guid of the domain to query for a DC
1132 * @param site Site of the domain to query for a DC
1133 * @param flags Bit flags used to control the domain location query
1134 * @param *dc_info Pointer to the returned extended domain controller information
1136 * @return #wbcErr
1138 wbcErr wbcLookupDomainControllerEx(const char *domain,
1139 struct wbcGuid *guid,
1140 const char *site,
1141 uint32_t flags,
1142 struct wbcDomainControllerInfoEx **dc_info);
1144 /**********************************************************
1145 * Athenticate functions
1146 **********************************************************/
1149 * @brief Authenticate a username/password pair
1151 * @param username Name of user to authenticate
1152 * @param password Clear text password os user
1154 * @return #wbcErr
1156 wbcErr wbcAuthenticateUser(const char *username,
1157 const char *password);
1160 * @brief Authenticate with more detailed information
1162 * @param params Input parameters, WBC_AUTH_USER_LEVEL_HASH
1163 * is not supported yet
1164 * @param info Output details on WBC_ERR_SUCCESS
1165 * @param error Output details on WBC_ERR_AUTH_ERROR
1167 * @return #wbcErr
1169 wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params,
1170 struct wbcAuthUserInfo **info,
1171 struct wbcAuthErrorInfo **error);
1174 * @brief Logon a User
1176 * @param[in] params Pointer to a wbcLogonUserParams structure
1177 * @param[out] info Pointer to a pointer to a wbcLogonUserInfo structure
1178 * @param[out] error Pointer to a pointer to a wbcAuthErrorInfo structure
1179 * @param[out] policy Pointer to a pointer to a wbcUserPasswordPolicyInfo structure
1181 * @return #wbcErr
1183 wbcErr wbcLogonUser(const struct wbcLogonUserParams *params,
1184 struct wbcLogonUserInfo **info,
1185 struct wbcAuthErrorInfo **error,
1186 struct wbcUserPasswordPolicyInfo **policy);
1189 * @brief Trigger a logoff notification to Winbind for a specific user
1191 * @param username Name of user to remove from Winbind's list of
1192 * logged on users.
1193 * @param uid Uid assigned to the username
1194 * @param ccfilename Absolute path to the Krb5 credentials cache to
1195 * be removed
1197 * @return #wbcErr
1199 wbcErr wbcLogoffUser(const char *username,
1200 uid_t uid,
1201 const char *ccfilename);
1204 * @brief Trigger an extended logoff notification to Winbind for a specific user
1206 * @param params A wbcLogoffUserParams structure
1207 * @param error User output details on error
1209 * @return #wbcErr
1211 wbcErr wbcLogoffUserEx(const struct wbcLogoffUserParams *params,
1212 struct wbcAuthErrorInfo **error);
1215 * @brief Change a password for a user
1217 * @param username Name of user to authenticate
1218 * @param old_password Old clear text password of user
1219 * @param new_password New clear text password of user
1221 * @return #wbcErr
1223 wbcErr wbcChangeUserPassword(const char *username,
1224 const char *old_password,
1225 const char *new_password);
1228 * @brief Change a password for a user with more detailed information upon
1229 * failure
1231 * @param params Input parameters
1232 * @param error User output details on WBC_ERR_PWD_CHANGE_FAILED
1233 * @param reject_reason New password reject reason on WBC_ERR_PWD_CHANGE_FAILED
1234 * @param policy Password policy output details on WBC_ERR_PWD_CHANGE_FAILED
1236 * @return #wbcErr
1238 wbcErr wbcChangeUserPasswordEx(const struct wbcChangePasswordParams *params,
1239 struct wbcAuthErrorInfo **error,
1240 enum wbcPasswordChangeRejectReason *reject_reason,
1241 struct wbcUserPasswordPolicyInfo **policy);
1244 * @brief Authenticate a user with cached credentials
1246 * @param *params Pointer to a wbcCredentialCacheParams structure
1247 * @param **info Pointer to a pointer to a wbcCredentialCacheInfo structure
1248 * @param **error Pointer to a pointer to a wbcAuthErrorInfo structure
1250 * @return #wbcErr
1252 wbcErr wbcCredentialCache(struct wbcCredentialCacheParams *params,
1253 struct wbcCredentialCacheInfo **info,
1254 struct wbcAuthErrorInfo **error);
1257 * @brief Save a password with winbind for doing wbcCredentialCache() later
1259 * @param *user Username
1260 * @param *password Password
1262 * @return #wbcErr
1264 wbcErr wbcCredentialSave(const char *user, const char *password);
1266 /**********************************************************
1267 * Resolve functions
1268 **********************************************************/
1271 * @brief Resolve a NetbiosName via WINS
1273 * @param name Name to resolve
1274 * @param *ip Pointer to the ip address string
1276 * @return #wbcErr
1278 wbcErr wbcResolveWinsByName(const char *name, char **ip);
1281 * @brief Resolve an IP address via WINS into a NetbiosName
1283 * @param ip The ip address string
1284 * @param *name Pointer to the name
1286 * @return #wbcErr
1289 wbcErr wbcResolveWinsByIP(const char *ip, char **name);
1291 /**********************************************************
1292 * Trusted domain functions
1293 **********************************************************/
1296 * @brief Trigger a verification of the trust credentials of a specific domain
1298 * @param *domain The name of the domain.
1299 * @param error Output details on WBC_ERR_AUTH_ERROR
1301 * @return #wbcErr
1303 wbcErr wbcCheckTrustCredentials(const char *domain,
1304 struct wbcAuthErrorInfo **error);
1307 * @brief Trigger a change of the trust credentials for a specific domain
1309 * @param *domain The name of the domain.
1310 * @param error Output details on WBC_ERR_AUTH_ERROR
1312 * @return #wbcErr
1314 wbcErr wbcChangeTrustCredentials(const char *domain,
1315 struct wbcAuthErrorInfo **error);
1318 * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost
1319 * version of wbcCheckTrustCredentials
1321 * @param *domain The name of the domain, only NULL for the default domain is
1322 * supported yet. Other values than NULL will result in
1323 * WBC_ERR_NOT_IMPLEMENTED.
1324 * @param error Output details on WBC_ERR_AUTH_ERROR
1326 * @return #wbcErr
1328 wbcErr wbcPingDc(const char *domain, struct wbcAuthErrorInfo **error);
1330 /**********************************************************
1331 * Helper functions
1332 **********************************************************/
1335 * @brief Initialize a named blob and add to list of blobs
1337 * @param[in,out] num_blobs Pointer to the number of blobs
1338 * @param[in,out] blobs Pointer to an array of blobs
1339 * @param[in] name Name of the new named blob
1340 * @param[in] flags Flags of the new named blob
1341 * @param[in] data Blob data of new blob
1342 * @param[in] length Blob data length of new blob
1344 * @return #wbcErr
1346 wbcErr wbcAddNamedBlob(size_t *num_blobs,
1347 struct wbcNamedBlob **blobs,
1348 const char *name,
1349 uint32_t flags,
1350 uint8_t *data,
1351 size_t length);
1353 #endif /* _WBCLIENT_H */