2 Unix SMB/CIFS implementation.
4 User credentials handling
6 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program 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
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "auth/gensec/gensec.h"
26 const struct gensec_security_ops **cli_credentials_gensec_list(struct cli_credentials *creds)
28 if (!creds || !creds->gensec_list) {
29 return gensec_security_all();
31 return creds->gensec_list;
34 static NTSTATUS cli_credentials_gensec_remove_mech(struct cli_credentials *creds,
35 const struct gensec_security_ops *remove_mech)
37 const struct gensec_security_ops **gensec_list;
38 const struct gensec_security_ops **new_gensec_list;
41 gensec_list = cli_credentials_gensec_list(creds);
43 for (i=0; gensec_list && gensec_list[i]; i++) {
47 new_gensec_list = talloc_array(creds, const struct gensec_security_ops *, i + 1);
48 if (!new_gensec_list) {
49 return NT_STATUS_NO_MEMORY;
53 for (i=0; gensec_list && gensec_list[i]; i++) {
54 if (gensec_list[i] != remove_mech) {
55 new_gensec_list[j] = gensec_list[i];
59 new_gensec_list[j] = NULL;
61 creds->gensec_list = new_gensec_list;
66 NTSTATUS cli_credentials_gensec_remove_oid(struct cli_credentials *creds,
69 const struct gensec_security_ops *gensec_by_oid;
71 gensec_by_oid = gensec_security_by_oid(NULL, oid);
76 return cli_credentials_gensec_remove_mech(creds, gensec_by_oid);