| 1 | /*
|
|---|
| 2 | Unix SMB/CIFS implementation.
|
|---|
| 3 |
|
|---|
| 4 | a async CLDAP library
|
|---|
| 5 |
|
|---|
| 6 | Copyright (C) Andrew Tridgell 2005
|
|---|
| 7 |
|
|---|
| 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 3 of the License, or
|
|---|
| 11 | (at your option) any later version.
|
|---|
| 12 |
|
|---|
| 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.
|
|---|
| 17 |
|
|---|
| 18 | You should have received a copy of the GNU General Public License
|
|---|
| 19 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 20 | */
|
|---|
| 21 |
|
|---|
| 22 | #include "../libcli/netlogon/netlogon.h"
|
|---|
| 23 |
|
|---|
| 24 | struct ldap_message;
|
|---|
| 25 | struct tsocket_address;
|
|---|
| 26 | struct cldap_socket;
|
|---|
| 27 |
|
|---|
| 28 | struct cldap_incoming {
|
|---|
| 29 | int recv_errno;
|
|---|
| 30 | uint8_t *buf;
|
|---|
| 31 | size_t len;
|
|---|
| 32 | struct tsocket_address *src;
|
|---|
| 33 | struct ldap_message *ldap_msg;
|
|---|
| 34 | };
|
|---|
| 35 |
|
|---|
| 36 | /*
|
|---|
| 37 | a general cldap search request
|
|---|
| 38 | */
|
|---|
| 39 | struct cldap_search {
|
|---|
| 40 | struct {
|
|---|
| 41 | const char *dest_address;
|
|---|
| 42 | uint16_t dest_port;
|
|---|
| 43 | const char *filter;
|
|---|
| 44 | const char * const *attributes;
|
|---|
| 45 | int timeout;
|
|---|
| 46 | int retries;
|
|---|
| 47 | } in;
|
|---|
| 48 | struct {
|
|---|
| 49 | struct ldap_SearchResEntry *response;
|
|---|
| 50 | struct ldap_Result *result;
|
|---|
| 51 | } out;
|
|---|
| 52 | };
|
|---|
| 53 |
|
|---|
| 54 | NTSTATUS cldap_socket_init(TALLOC_CTX *mem_ctx,
|
|---|
| 55 | struct tevent_context *ev,
|
|---|
| 56 | const struct tsocket_address *local_addr,
|
|---|
| 57 | const struct tsocket_address *remote_addr,
|
|---|
| 58 | struct cldap_socket **_cldap);
|
|---|
| 59 |
|
|---|
| 60 | NTSTATUS cldap_set_incoming_handler(struct cldap_socket *cldap,
|
|---|
| 61 | void (*handler)(struct cldap_socket *,
|
|---|
| 62 | void *private_data,
|
|---|
| 63 | struct cldap_incoming *),
|
|---|
| 64 | void *private_data);
|
|---|
| 65 | struct tevent_req *cldap_search_send(TALLOC_CTX *mem_ctx,
|
|---|
| 66 | struct cldap_socket *cldap,
|
|---|
| 67 | const struct cldap_search *io);
|
|---|
| 68 | NTSTATUS cldap_search_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
|
|---|
| 69 | struct cldap_search *io);
|
|---|
| 70 | NTSTATUS cldap_search(struct cldap_socket *cldap, TALLOC_CTX *mem_ctx,
|
|---|
| 71 | struct cldap_search *io);
|
|---|
| 72 |
|
|---|
| 73 | /*
|
|---|
| 74 | a general cldap reply
|
|---|
| 75 | */
|
|---|
| 76 | struct cldap_reply {
|
|---|
| 77 | uint32_t messageid;
|
|---|
| 78 | struct tsocket_address *dest;
|
|---|
| 79 | struct ldap_SearchResEntry *response;
|
|---|
| 80 | struct ldap_Result *result;
|
|---|
| 81 | };
|
|---|
| 82 |
|
|---|
| 83 | NTSTATUS cldap_reply_send(struct cldap_socket *cldap, struct cldap_reply *io);
|
|---|
| 84 |
|
|---|
| 85 | NTSTATUS cldap_empty_reply(struct cldap_socket *cldap,
|
|---|
| 86 | uint32_t message_id,
|
|---|
| 87 | struct tsocket_address *dst);
|
|---|
| 88 | NTSTATUS cldap_error_reply(struct cldap_socket *cldap,
|
|---|
| 89 | uint32_t message_id,
|
|---|
| 90 | struct tsocket_address *dst,
|
|---|
| 91 | int resultcode,
|
|---|
| 92 | const char *errormessage);
|
|---|
| 93 |
|
|---|
| 94 | /*
|
|---|
| 95 | a netlogon cldap request
|
|---|
| 96 | */
|
|---|
| 97 | struct cldap_netlogon {
|
|---|
| 98 | struct {
|
|---|
| 99 | const char *dest_address;
|
|---|
| 100 | uint16_t dest_port;
|
|---|
| 101 | const char *realm;
|
|---|
| 102 | const char *host;
|
|---|
| 103 | const char *user;
|
|---|
| 104 | const char *domain_guid;
|
|---|
| 105 | const char *domain_sid;
|
|---|
| 106 | int acct_control;
|
|---|
| 107 | uint32_t version;
|
|---|
| 108 | bool map_response;
|
|---|
| 109 | } in;
|
|---|
| 110 | struct {
|
|---|
| 111 | struct netlogon_samlogon_response netlogon;
|
|---|
| 112 | } out;
|
|---|
| 113 | };
|
|---|
| 114 |
|
|---|
| 115 | struct tevent_req *cldap_netlogon_send(TALLOC_CTX *mem_ctx,
|
|---|
| 116 | struct cldap_socket *cldap,
|
|---|
| 117 | const struct cldap_netlogon *io);
|
|---|
| 118 | NTSTATUS cldap_netlogon_recv(struct tevent_req *req,
|
|---|
| 119 | TALLOC_CTX *mem_ctx,
|
|---|
| 120 | struct cldap_netlogon *io);
|
|---|
| 121 | NTSTATUS cldap_netlogon(struct cldap_socket *cldap,
|
|---|
| 122 | TALLOC_CTX *mem_ctx,
|
|---|
| 123 | struct cldap_netlogon *io);
|
|---|
| 124 |
|
|---|
| 125 | NTSTATUS cldap_netlogon_reply(struct cldap_socket *cldap,
|
|---|
| 126 | uint32_t message_id,
|
|---|
| 127 | struct tsocket_address *dst,
|
|---|
| 128 | uint32_t version,
|
|---|
| 129 | struct netlogon_samlogon_response *netlogon);
|
|---|
| 130 |
|
|---|