2 Unix SMB/Netbios implementation.
4 ads (active directory) utility library
5 Copyright (C) Andrew Tridgell 2001
6 Copyright (C) Remus Koos 2001
7 Copyright (C) Andrew Bartlett 2001
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 build a ADS_STATUS structure
30 ADS_STATUS ads_build_error(enum ads_error_type etype,
31 int rc, int minor_status)
34 ret.error_type = etype;
36 ret.minor_status = minor_status;
41 do a rough conversion between ads error codes and NT status codes
42 we'll need to fill this in more
44 NTSTATUS ads_ntstatus(ADS_STATUS rc)
46 if (ADS_ERR_OK(rc)) return NT_STATUS_OK;
47 return NT_STATUS_UNSUCCESSFUL;
51 return a string for an error from a ads routine
53 const char *ads_errstr(ADS_STATUS status)
62 switch (status.error_type) {
63 case ADS_ERROR_SYSTEM:
64 return strerror(status.rc);
67 return ldap_err2string(status.rc);
71 return error_message(status.rc);
74 gss_buffer_desc msg1, msg2;
77 gss_display_status(&minor, status.rc, GSS_C_GSS_CODE,
78 GSS_C_NULL_OID, &msg_ctx, &msg1);
79 gss_display_status(&minor, status.minor_status, GSS_C_MECH_CODE,
80 GSS_C_NULL_OID, &msg_ctx, &msg2);
81 asprintf(&ret, "%s : %s", (char *)msg1.value, (char *)msg2.value);
82 gss_release_buffer(&minor, &msg1);
83 gss_release_buffer(&minor, &msg2);
88 return "Unknown ADS error type!? (not compiled in?)";