2 Unix SMB/CIFS implementation.
6 Copyright (C) Gerald (Jerry) Carter 2007
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 /* Required Headers */
25 #include "libwbclient.h"
29 /** @brief Ping winbindd to see if the daemon is running
36 struct winbindd_request request;
37 struct winbindd_response response;
39 /* Initialize request */
42 ZERO_STRUCT(response);
44 return wbcRequestResponse(WINBINDD_PING, &request, &response);
47 /** @brief Lookup the current status of a trusted domain
49 * @param domain Domain to query
50 * @param *dinfo Pointer to returned domain_info struct
57 wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo)
59 struct winbindd_request request;
60 struct winbindd_response response;
61 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
62 struct wbcDomainInfo *info = NULL;
64 if (!domain || !dinfo) {
65 wbc_status = WBC_ERR_INVALID_PARAM;
66 BAIL_ON_WBC_ERROR(wbc_status);
69 /* Initialize request */
72 ZERO_STRUCT(response);
74 strncpy(request.domain_name, domain,
75 sizeof(request.domain_name)-1);
77 wbc_status = wbcRequestResponse(WINBINDD_DOMAIN_INFO,
80 BAIL_ON_WBC_ERROR(wbc_status);
82 info = talloc(NULL, struct wbcDomainInfo);
83 BAIL_ON_PTR_ERROR(info, wbc_status);
85 info->short_name = talloc_strdup(info,
86 response.data.domain_info.name);
87 BAIL_ON_PTR_ERROR(info->short_name, wbc_status);
89 info->dns_name = talloc_strdup(info,
90 response.data.domain_info.alt_name);
91 BAIL_ON_PTR_ERROR(info->dns_name, wbc_status);
93 wbc_status = wbcStringToSid(response.data.domain_info.sid,
95 BAIL_ON_WBC_ERROR(wbc_status);
97 if (response.data.domain_info.native_mode)
98 info->flags |= WBC_DOMINFO_NATIVE;
99 if (response.data.domain_info.active_directory)
100 info->flags |= WBC_DOMINFO_AD;
101 if (response.data.domain_info.primary)
102 info->flags |= WBC_DOMINFO_PRIMARY;
106 wbc_status = WBC_ERR_SUCCESS;
109 if (!WBC_ERROR_IS_OK(wbc_status)) {