2005-05-10 06:01:25 +04:00
/*
Unix SMB / CIFS implementation .
a async CLDAP library
Copyright ( C ) Andrew Tridgell 2005
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
2006-01-03 18:40:05 +03:00
# include "libcli/util/asn_1.h"
2005-05-10 06:01:25 +04:00
# include "librpc/gen_ndr/ndr_nbt.h"
2006-01-03 20:27:33 +03:00
struct ldap_message ;
2005-05-10 06:01:25 +04:00
enum cldap_request_state { CLDAP_REQUEST_SEND ,
CLDAP_REQUEST_WAIT ,
CLDAP_REQUEST_DONE ,
CLDAP_REQUEST_TIMEOUT } ;
/*
a cldap request packet
*/
struct cldap_request {
struct cldap_request * next , * prev ;
struct cldap_socket * cldap ;
enum cldap_request_state state ;
/* where to send the request */
2006-01-10 01:12:53 +03:00
struct socket_address * dest ;
2005-05-10 06:01:25 +04:00
/* timeout between retries (seconds) */
int timeout ;
int num_retries ;
2005-05-12 12:25:35 +04:00
BOOL is_reply ;
2005-05-10 06:01:25 +04:00
/* the ldap message_id */
int message_id ;
struct timed_event * te ;
/* the encoded request */
DATA_BLOB encoded ;
/* the reply data */
struct asn1_data asn1 ;
/* information on what to do on completion */
struct {
void ( * fn ) ( struct cldap_request * ) ;
void * private ;
} async ;
} ;
/*
context structure for operations on cldap packets
*/
struct cldap_socket {
struct socket_context * sock ;
struct event_context * event_ctx ;
/* the fd event */
struct fd_event * fde ;
/* a queue of outgoing requests */
struct cldap_request * send_queue ;
/* mapping from message_id to pending request */
struct idr_context * idr ;
/* what to do with incoming request packets */
struct {
void ( * handler ) ( struct cldap_socket * , struct ldap_message * ,
2006-01-10 01:12:53 +03:00
struct socket_address * ) ;
2005-05-10 06:01:25 +04:00
void * private ;
} incoming ;
} ;
/*
a general cldap search request
*/
struct cldap_search {
struct {
const char * dest_address ;
const char * filter ;
const char * * attributes ;
int timeout ;
int retries ;
} in ;
struct {
struct ldap_SearchResEntry * response ;
struct ldap_Result * result ;
} out ;
} ;
struct cldap_socket * cldap_socket_init ( TALLOC_CTX * mem_ctx ,
struct event_context * event_ctx ) ;
2005-05-11 08:48:30 +04:00
NTSTATUS cldap_set_incoming_handler ( struct cldap_socket * cldap ,
void ( * handler ) ( struct cldap_socket * , struct ldap_message * ,
2006-01-10 01:12:53 +03:00
struct socket_address * ) ,
2005-05-11 08:48:30 +04:00
void * private ) ;
2005-05-10 06:01:25 +04:00
struct cldap_request * cldap_search_send ( struct cldap_socket * cldap ,
struct cldap_search * io ) ;
NTSTATUS cldap_search_recv ( struct cldap_request * req , TALLOC_CTX * mem_ctx ,
struct cldap_search * io ) ;
NTSTATUS cldap_search ( struct cldap_socket * cldap , TALLOC_CTX * mem_ctx ,
struct cldap_search * io ) ;
2005-05-12 12:25:35 +04:00
/*
a general cldap reply
*/
struct cldap_reply {
uint32_t messageid ;
2006-01-10 01:12:53 +03:00
struct socket_address * dest ;
2005-05-12 12:25:35 +04:00
struct ldap_SearchResEntry * response ;
struct ldap_Result * result ;
} ;
NTSTATUS cldap_reply_send ( struct cldap_socket * cldap , struct cldap_reply * io ) ;
2005-05-10 06:01:25 +04:00
/*
a netlogon cldap request
*/
struct cldap_netlogon {
struct {
const char * dest_address ;
const char * realm ;
const char * host ;
2005-05-13 10:08:49 +04:00
const char * user ;
const char * domain_guid ;
const char * domain_sid ;
int acct_control ;
uint32_t version ;
2005-05-10 06:01:25 +04:00
} in ;
struct {
2005-05-11 03:33:56 +04:00
union nbt_cldap_netlogon netlogon ;
2005-05-10 06:01:25 +04:00
} out ;
} ;
struct cldap_request * cldap_netlogon_send ( struct cldap_socket * cldap ,
struct cldap_netlogon * io ) ;
NTSTATUS cldap_netlogon_recv ( struct cldap_request * req ,
TALLOC_CTX * mem_ctx ,
struct cldap_netlogon * io ) ;
NTSTATUS cldap_netlogon ( struct cldap_socket * cldap ,
TALLOC_CTX * mem_ctx , struct cldap_netlogon * io ) ;
2005-05-12 12:25:35 +04:00
NTSTATUS cldap_empty_reply ( struct cldap_socket * cldap ,
uint32_t message_id ,
2006-01-10 01:12:53 +03:00
struct socket_address * src ) ;
2005-05-12 12:25:35 +04:00
NTSTATUS cldap_netlogon_reply ( struct cldap_socket * cldap ,
uint32_t message_id ,
2006-01-10 01:12:53 +03:00
struct socket_address * src ,
2005-05-12 12:25:35 +04:00
uint32_t version ,
union nbt_cldap_netlogon * netlogon ) ;