radcli 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGES +0 -0
- data/LICENSE +201 -0
- data/MANIFEST +13 -0
- data/README.md +109 -0
- data/Rakefile +65 -0
- data/build_adcli.sh +6 -0
- data/ext/lib/libadcli.a +0 -0
- data/ext/radcli/adconn.h +147 -0
- data/ext/radcli/adenroll.h +143 -0
- data/ext/radcli/adutil.h +94 -0
- data/ext/radcli/extconf.rb +16 -0
- data/ext/radcli/radcli.c +13 -0
- data/ext/radcli/radcli.h +31 -0
- data/ext/radcli/radconn.c +291 -0
- data/ext/radcli/radenroll.c +278 -0
- data/radcli.gemspec +26 -0
- data/scripts/delete.rb +20 -0
- data/scripts/fail_adconnect.rb +46 -0
- data/scripts/join.rb +22 -0
- data/scripts/reset.rb +24 -0
- data/test/test_radconn.rb +110 -0
- data/test/test_radenroll.rb +74 -0
- metadata +104 -0
@@ -0,0 +1,143 @@
|
|
1
|
+
/*
|
2
|
+
* adcli
|
3
|
+
*
|
4
|
+
* Copyright (C) 2012 Red Hat Inc.
|
5
|
+
*
|
6
|
+
* This program is free software; you can redistribute it and/or modify
|
7
|
+
* it under the terms of the GNU Lesser General Public License as
|
8
|
+
* published by the Free Software Foundation; either version 2.1 of
|
9
|
+
* the License, or (at your option) any later version.
|
10
|
+
*
|
11
|
+
* This program is distributed in the hope that it will be useful, but
|
12
|
+
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
* Lesser General Public License for more details.
|
15
|
+
*
|
16
|
+
* You should have received a copy of the GNU Lesser General Public
|
17
|
+
* License along with this program; if not, write to the Free Software
|
18
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19
|
+
* MA 02110-1301 USA
|
20
|
+
*
|
21
|
+
* Author: Stef Walter <stefw@gnome.org>
|
22
|
+
*/
|
23
|
+
|
24
|
+
#ifndef ADENROLL_H_
|
25
|
+
#define ADENROLL_H_
|
26
|
+
|
27
|
+
#include "adconn.h"
|
28
|
+
|
29
|
+
typedef enum {
|
30
|
+
ADCLI_ENROLL_NO_KEYTAB = 1 << 1,
|
31
|
+
ADCLI_ENROLL_ALLOW_OVERWRITE = 1 << 2,
|
32
|
+
ADCLI_ENROLL_PASSWORD_VALID = 1 << 3,
|
33
|
+
} adcli_enroll_flags;
|
34
|
+
|
35
|
+
typedef struct _adcli_enroll adcli_enroll;
|
36
|
+
|
37
|
+
adcli_result adcli_enroll_prepare (adcli_enroll *enroll,
|
38
|
+
adcli_enroll_flags flags);
|
39
|
+
|
40
|
+
adcli_result adcli_enroll_load (adcli_enroll *enroll);
|
41
|
+
|
42
|
+
adcli_result adcli_enroll_join (adcli_enroll *enroll,
|
43
|
+
adcli_enroll_flags join_flags);
|
44
|
+
|
45
|
+
adcli_result adcli_enroll_update (adcli_enroll *enroll,
|
46
|
+
adcli_enroll_flags flags);
|
47
|
+
|
48
|
+
adcli_result adcli_enroll_delete (adcli_enroll *enroll,
|
49
|
+
adcli_enroll_flags delete_flags);
|
50
|
+
|
51
|
+
adcli_result adcli_enroll_password (adcli_enroll *enroll,
|
52
|
+
adcli_enroll_flags password_flags);
|
53
|
+
|
54
|
+
adcli_enroll * adcli_enroll_new (adcli_conn *conn);
|
55
|
+
|
56
|
+
adcli_enroll * adcli_enroll_ref (adcli_enroll *enroll);
|
57
|
+
|
58
|
+
void adcli_enroll_unref (adcli_enroll *enroll);
|
59
|
+
|
60
|
+
const char * adcli_enroll_get_host_fqdn (adcli_enroll *enroll);
|
61
|
+
|
62
|
+
void adcli_enroll_set_host_fqdn (adcli_enroll *enroll,
|
63
|
+
const char *value);
|
64
|
+
|
65
|
+
const char * adcli_enroll_get_computer_name (adcli_enroll *enroll);
|
66
|
+
|
67
|
+
void adcli_enroll_set_computer_name (adcli_enroll *enroll,
|
68
|
+
const char *value);
|
69
|
+
|
70
|
+
const char * adcli_enroll_get_computer_password (adcli_enroll *enroll);
|
71
|
+
|
72
|
+
void adcli_enroll_set_computer_password (adcli_enroll *enroll,
|
73
|
+
const char *host_password);
|
74
|
+
|
75
|
+
void adcli_enroll_reset_computer_password (adcli_enroll *enroll);
|
76
|
+
|
77
|
+
const char * adcli_enroll_get_domain_ou (adcli_enroll *enroll);
|
78
|
+
|
79
|
+
void adcli_enroll_set_domain_ou (adcli_enroll *enroll,
|
80
|
+
const char *value);
|
81
|
+
|
82
|
+
const char * adcli_enroll_get_computer_dn (adcli_enroll *enroll);
|
83
|
+
|
84
|
+
void adcli_enroll_set_computer_dn (adcli_enroll *enroll,
|
85
|
+
const char *value);
|
86
|
+
|
87
|
+
const char ** adcli_enroll_get_service_names (adcli_enroll *enroll);
|
88
|
+
|
89
|
+
void adcli_enroll_set_service_names (adcli_enroll *enroll,
|
90
|
+
const char **value);
|
91
|
+
|
92
|
+
void adcli_enroll_add_service_name (adcli_enroll *enroll,
|
93
|
+
const char *value);
|
94
|
+
|
95
|
+
const char ** adcli_enroll_get_service_principals (adcli_enroll *enroll);
|
96
|
+
|
97
|
+
void adcli_enroll_set_service_principals (adcli_enroll *enroll,
|
98
|
+
const char **value);
|
99
|
+
|
100
|
+
const char * adcli_enroll_get_user_principal (adcli_enroll *enroll);
|
101
|
+
|
102
|
+
void adcli_enroll_set_user_principal (adcli_enroll *enroll,
|
103
|
+
const char *value);
|
104
|
+
|
105
|
+
void adcli_enroll_auto_user_principal (adcli_enroll *enroll);
|
106
|
+
|
107
|
+
unsigned int adcli_enroll_get_computer_password_lifetime (adcli_enroll *enroll);
|
108
|
+
void adcli_enroll_set_computer_password_lifetime (adcli_enroll *enroll,
|
109
|
+
unsigned int lifetime);
|
110
|
+
|
111
|
+
krb5_kvno adcli_enroll_get_kvno (adcli_enroll *enroll);
|
112
|
+
|
113
|
+
void adcli_enroll_set_kvno (adcli_enroll *enroll,
|
114
|
+
krb5_kvno value);
|
115
|
+
|
116
|
+
krb5_keytab adcli_enroll_get_keytab (adcli_enroll *enroll);
|
117
|
+
|
118
|
+
const char * adcli_enroll_get_keytab_name (adcli_enroll *enroll);
|
119
|
+
|
120
|
+
void adcli_enroll_set_keytab_name (adcli_enroll *enroll,
|
121
|
+
const char *value);
|
122
|
+
|
123
|
+
krb5_enctype * adcli_enroll_get_keytab_enctypes (adcli_enroll *enroll);
|
124
|
+
|
125
|
+
void adcli_enroll_set_keytab_enctypes (adcli_enroll *enroll,
|
126
|
+
krb5_enctype *enctypes);
|
127
|
+
|
128
|
+
const char * adcli_enroll_get_os_name (adcli_enroll *enroll);
|
129
|
+
|
130
|
+
void adcli_enroll_set_os_name (adcli_enroll *enroll,
|
131
|
+
const char *value);
|
132
|
+
|
133
|
+
const char * adcli_enroll_get_os_version (adcli_enroll *enroll);
|
134
|
+
|
135
|
+
void adcli_enroll_set_os_version (adcli_enroll *enroll,
|
136
|
+
const char *value);
|
137
|
+
|
138
|
+
const char * adcli_enroll_get_os_service_pack (adcli_enroll *enroll);
|
139
|
+
|
140
|
+
void adcli_enroll_set_os_service_pack (adcli_enroll *enroll,
|
141
|
+
const char *value);
|
142
|
+
|
143
|
+
#endif /* ADENROLL_H_ */
|
data/ext/radcli/adutil.h
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
/*
|
2
|
+
* adcli
|
3
|
+
*
|
4
|
+
* Copyright (C) 2012 Red Hat Inc.
|
5
|
+
*
|
6
|
+
* This program is free software; you can redistribute it and/or modify
|
7
|
+
* it under the terms of the GNU Lesser General Public License as
|
8
|
+
* published by the Free Software Foundation; either version 2.1 of
|
9
|
+
* the License, or (at your option) any later version.
|
10
|
+
*
|
11
|
+
* This program is distributed in the hope that it will be useful, but
|
12
|
+
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
* Lesser General Public License for more details.
|
15
|
+
*
|
16
|
+
* You should have received a copy of the GNU Lesser General Public
|
17
|
+
* License along with this program; if not, write to the Free Software
|
18
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19
|
+
* MA 02110-1301 USA
|
20
|
+
*
|
21
|
+
* Author: Stef Walter <stefw@gnome.org>
|
22
|
+
*/
|
23
|
+
|
24
|
+
#ifndef ADUTIL_H_
|
25
|
+
#define ADUTIL_H_
|
26
|
+
|
27
|
+
#include <stdlib.h>
|
28
|
+
#include <stdbool.h>
|
29
|
+
|
30
|
+
typedef enum {
|
31
|
+
/* Successful completion */
|
32
|
+
ADCLI_SUCCESS = 0,
|
33
|
+
|
34
|
+
/*
|
35
|
+
* Invalid input or unexpected system behavior.
|
36
|
+
*
|
37
|
+
* This is almost always caused by a bug, or completely broken
|
38
|
+
* system configuration or state. This is returned when memory
|
39
|
+
* allocation fails, but the process will almost certainly have
|
40
|
+
* been killed first.
|
41
|
+
*
|
42
|
+
* This is returned for invalid inputs (such an unexpected
|
43
|
+
* NULL) to adcli.
|
44
|
+
*/
|
45
|
+
ADCLI_ERR_UNEXPECTED = -2,
|
46
|
+
|
47
|
+
/*
|
48
|
+
* A general failure, that doesn't fit into the other categories.
|
49
|
+
* Not much the caller can do.
|
50
|
+
*/
|
51
|
+
ADCLI_ERR_FAIL = -3,
|
52
|
+
|
53
|
+
/*
|
54
|
+
* A problem with the active directory or connecting to it.
|
55
|
+
*/
|
56
|
+
ADCLI_ERR_DIRECTORY = -4,
|
57
|
+
|
58
|
+
/*
|
59
|
+
* A logic problem with the configuration of the local system, or
|
60
|
+
* the settings passed into adcli.
|
61
|
+
*/
|
62
|
+
ADCLI_ERR_CONFIG = -5,
|
63
|
+
|
64
|
+
/*
|
65
|
+
* Invalid credentials.
|
66
|
+
*
|
67
|
+
* The credentials are invalid, or don't have the necessary
|
68
|
+
* access rights.
|
69
|
+
*/
|
70
|
+
ADCLI_ERR_CREDENTIALS = -6,
|
71
|
+
} adcli_result;
|
72
|
+
|
73
|
+
typedef enum {
|
74
|
+
ADCLI_MESSAGE_INFO,
|
75
|
+
ADCLI_MESSAGE_WARNING,
|
76
|
+
ADCLI_MESSAGE_ERROR
|
77
|
+
} adcli_message_type;
|
78
|
+
|
79
|
+
const char * adcli_result_to_string (adcli_result res);
|
80
|
+
|
81
|
+
int adcli_mem_clear (void *data,
|
82
|
+
size_t length);
|
83
|
+
|
84
|
+
|
85
|
+
typedef void (* adcli_message_func) (adcli_message_type type,
|
86
|
+
const char *message);
|
87
|
+
|
88
|
+
void adcli_set_message_func (adcli_message_func message_func);
|
89
|
+
|
90
|
+
void adcli_clear_last_error (void);
|
91
|
+
|
92
|
+
const char * adcli_get_last_error (void);
|
93
|
+
|
94
|
+
#endif /* ADUTIL_H_ */
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "mkmf"
|
2
|
+
|
3
|
+
LIBDIR = RbConfig::CONFIG['libdir']
|
4
|
+
INCLUDEDIR = RbConfig::CONFIG['includedir']
|
5
|
+
HEADER_DIRS = [INCLUDEDIR, File.expand_path(File.join(File.dirname(__FILE__), "ext/radcli"))]
|
6
|
+
LIB_DIRS = [LIBDIR, File.expand_path(File.join(File.dirname(__FILE__), "../lib"))]
|
7
|
+
libs = ['-ladcli', '-lldap', '-lkrb5', '-lsasl2', '-lgssapi_krb5']
|
8
|
+
|
9
|
+
dir_config('radcli', HEADER_DIRS, LIB_DIRS)
|
10
|
+
|
11
|
+
libs.each do |lib|
|
12
|
+
$LOCAL_LIBS << "#{lib} "
|
13
|
+
end
|
14
|
+
|
15
|
+
create_makefile('radcli')
|
16
|
+
|
data/ext/radcli/radcli.c
ADDED
data/ext/radcli/radcli.h
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#ifndef ADCLI_H_INCLUDED
|
2
|
+
#define ADCLI_H_INCLUDED
|
3
|
+
|
4
|
+
#include <ruby.h>
|
5
|
+
#include <adconn.h>
|
6
|
+
#include <adenroll.h>
|
7
|
+
#include <stdio.h>
|
8
|
+
#include <errno.h>
|
9
|
+
|
10
|
+
// Function prototypes
|
11
|
+
void Init_AdConn();
|
12
|
+
void Init_AdEnroll();
|
13
|
+
|
14
|
+
// Variable declarations
|
15
|
+
extern VALUE m_adcli;
|
16
|
+
extern VALUE c_adconn;
|
17
|
+
extern VALUE c_adenroll;
|
18
|
+
extern VALUE c_adconn_exception;
|
19
|
+
extern VALUE c_adenroll_exception;
|
20
|
+
|
21
|
+
// Adcli::AdConn
|
22
|
+
typedef struct {
|
23
|
+
adcli_conn *conn;
|
24
|
+
} RUBY_ADCONN;
|
25
|
+
|
26
|
+
// Adcli::AdEnroll
|
27
|
+
typedef struct {
|
28
|
+
adcli_enroll *enroll;
|
29
|
+
} RUBY_ADENROLL;
|
30
|
+
|
31
|
+
#endif
|
@@ -0,0 +1,291 @@
|
|
1
|
+
#include <radcli.h>
|
2
|
+
|
3
|
+
VALUE c_adconn;
|
4
|
+
|
5
|
+
// Free function for the Adcli::Adconn class.
|
6
|
+
static void radcli_free (RUBY_ADCONN* ptr) {
|
7
|
+
if(!ptr)
|
8
|
+
return;
|
9
|
+
|
10
|
+
adcli_conn_unref (ptr->conn);
|
11
|
+
|
12
|
+
free (ptr);
|
13
|
+
}
|
14
|
+
|
15
|
+
// Allocation function for the Adcli:Adconn class.
|
16
|
+
static VALUE radconn_allocate (VALUE klass) {
|
17
|
+
RUBY_ADCONN* ptr = malloc (sizeof(RUBY_ADCONN));
|
18
|
+
|
19
|
+
memset (ptr, 0, sizeof(RUBY_ADCONN));
|
20
|
+
|
21
|
+
return Data_Wrap_Struct (klass, 0, radcli_free, ptr);
|
22
|
+
}
|
23
|
+
|
24
|
+
/*
|
25
|
+
* call-seq:
|
26
|
+
* Adcli::Adconn.new("domain.com")
|
27
|
+
*
|
28
|
+
* Creates and returns a new Adcli::Adconn object.
|
29
|
+
*
|
30
|
+
*/
|
31
|
+
static VALUE radconn_initialize (VALUE self, VALUE domain) {
|
32
|
+
RUBY_ADCONN* ptr;
|
33
|
+
|
34
|
+
Check_Type(domain, T_STRING);
|
35
|
+
|
36
|
+
const char *domain_name = StringValuePtr(domain);
|
37
|
+
|
38
|
+
Data_Get_Struct (self, RUBY_ADCONN, ptr);
|
39
|
+
|
40
|
+
ptr->conn = adcli_conn_new (domain_name);
|
41
|
+
|
42
|
+
return self;
|
43
|
+
}
|
44
|
+
|
45
|
+
/*
|
46
|
+
* call-seq:
|
47
|
+
* Adcli::Adconn.set_login_ccache_name("")
|
48
|
+
*
|
49
|
+
* Set the login kerberos cache name
|
50
|
+
*
|
51
|
+
*/
|
52
|
+
static VALUE radconn_set_login_ccache_name (VALUE self, VALUE ccname) {
|
53
|
+
RUBY_ADCONN* ptr;
|
54
|
+
|
55
|
+
Check_Type(ccname, T_STRING);
|
56
|
+
|
57
|
+
const char *c_ccname = StringValuePtr(ccname);
|
58
|
+
|
59
|
+
Data_Get_Struct (self, RUBY_ADCONN, ptr);
|
60
|
+
|
61
|
+
adcli_conn_set_login_ccache_name (ptr->conn, c_ccname);
|
62
|
+
|
63
|
+
return self;
|
64
|
+
}
|
65
|
+
|
66
|
+
/*
|
67
|
+
* call-seq:
|
68
|
+
* Adcli::Adconn.get_login_ccache_name()
|
69
|
+
*
|
70
|
+
* Get the login kerberos cache name
|
71
|
+
*
|
72
|
+
*/
|
73
|
+
static VALUE radconn_get_login_ccache_name (VALUE self) {
|
74
|
+
RUBY_ADCONN* ptr;
|
75
|
+
const char *login_ccache = NULL;
|
76
|
+
|
77
|
+
Data_Get_Struct (self, RUBY_ADCONN, ptr);
|
78
|
+
|
79
|
+
login_ccache = adcli_conn_get_login_ccache_name (ptr->conn);
|
80
|
+
|
81
|
+
return rb_str_new_cstr (login_ccache);
|
82
|
+
}
|
83
|
+
|
84
|
+
/*
|
85
|
+
* call-seq:
|
86
|
+
* Adcli::Adconn.set_login_user("user")
|
87
|
+
*
|
88
|
+
* Sets the login user that we should authenticate as.
|
89
|
+
*
|
90
|
+
*/
|
91
|
+
static VALUE radconn_set_login_user (VALUE self, VALUE user) {
|
92
|
+
RUBY_ADCONN* ptr;
|
93
|
+
|
94
|
+
Check_Type(user, T_STRING);
|
95
|
+
|
96
|
+
const char *c_user = StringValuePtr(user);
|
97
|
+
|
98
|
+
Data_Get_Struct (self, RUBY_ADCONN, ptr);
|
99
|
+
|
100
|
+
adcli_conn_set_login_user (ptr->conn, c_user);
|
101
|
+
|
102
|
+
return self;
|
103
|
+
}
|
104
|
+
|
105
|
+
/*
|
106
|
+
* call-seq:
|
107
|
+
* Adcli::Adconn.get_login_user # => 'user'
|
108
|
+
*
|
109
|
+
* Get the login user for authentication.
|
110
|
+
*
|
111
|
+
*/
|
112
|
+
static VALUE radconn_get_login_user (VALUE self) {
|
113
|
+
RUBY_ADCONN* ptr;
|
114
|
+
const char *login_user = NULL;
|
115
|
+
|
116
|
+
Data_Get_Struct (self, RUBY_ADCONN, ptr);
|
117
|
+
|
118
|
+
login_user = adcli_conn_get_login_user (ptr->conn);
|
119
|
+
|
120
|
+
return rb_str_new_cstr (login_user);
|
121
|
+
}
|
122
|
+
|
123
|
+
/*
|
124
|
+
* call-seq:
|
125
|
+
* Adcli::Adconn.set_user_password
|
126
|
+
*
|
127
|
+
* Sets the login user password for authentication.
|
128
|
+
*
|
129
|
+
*/
|
130
|
+
static VALUE radconn_set_user_password (VALUE self, VALUE password) {
|
131
|
+
RUBY_ADCONN* ptr;
|
132
|
+
|
133
|
+
Check_Type(password, T_STRING);
|
134
|
+
|
135
|
+
const char *c_password = StringValuePtr(password);
|
136
|
+
|
137
|
+
Data_Get_Struct (self, RUBY_ADCONN, ptr);
|
138
|
+
|
139
|
+
adcli_conn_set_user_password (ptr->conn, c_password);
|
140
|
+
|
141
|
+
return self;
|
142
|
+
}
|
143
|
+
|
144
|
+
/*
|
145
|
+
* call-seq:
|
146
|
+
* Adcli::Adconn.get_user_password
|
147
|
+
*
|
148
|
+
* Gets the login user password for authentication.
|
149
|
+
*
|
150
|
+
*/
|
151
|
+
static VALUE radconn_get_user_password (VALUE self) {
|
152
|
+
RUBY_ADCONN* ptr;
|
153
|
+
const char *login_password = NULL;
|
154
|
+
|
155
|
+
Data_Get_Struct (self, RUBY_ADCONN, ptr);
|
156
|
+
|
157
|
+
login_password = adcli_conn_get_user_password(ptr->conn);
|
158
|
+
|
159
|
+
return rb_str_new_cstr(login_password);
|
160
|
+
}
|
161
|
+
|
162
|
+
/*
|
163
|
+
* call-seq:
|
164
|
+
* Adcli::Adconn.get_domain_realm # => 'YOUR.REALM.COM'
|
165
|
+
*
|
166
|
+
* Gets the domain realm.
|
167
|
+
*
|
168
|
+
*/
|
169
|
+
static VALUE radconn_get_domain_realm (VALUE self) {
|
170
|
+
RUBY_ADCONN* ptr;
|
171
|
+
const char *domain_realm = NULL;
|
172
|
+
|
173
|
+
Data_Get_Struct (self ,RUBY_ADCONN, ptr);
|
174
|
+
|
175
|
+
domain_realm = adcli_conn_get_domain_realm(ptr->conn);
|
176
|
+
|
177
|
+
return rb_str_new_cstr (domain_realm);
|
178
|
+
}
|
179
|
+
|
180
|
+
/*
|
181
|
+
* call-seq:
|
182
|
+
* Adcli::Adconn.set_domain_realm('YOUR.REALM.COM')
|
183
|
+
*
|
184
|
+
* Set the domain realm.
|
185
|
+
*
|
186
|
+
*/
|
187
|
+
static VALUE radconn_set_domain_realm (VALUE self, VALUE domain_realm) {
|
188
|
+
RUBY_ADCONN* ptr;
|
189
|
+
|
190
|
+
Check_Type(domain_realm, T_STRING);
|
191
|
+
|
192
|
+
char *c_domain_realm = StringValuePtr(domain_realm);
|
193
|
+
|
194
|
+
Data_Get_Struct (self, RUBY_ADCONN, ptr);
|
195
|
+
|
196
|
+
adcli_conn_set_domain_realm (ptr->conn, c_domain_realm);
|
197
|
+
|
198
|
+
return self;
|
199
|
+
}
|
200
|
+
|
201
|
+
|
202
|
+
/*
|
203
|
+
* call-seq:
|
204
|
+
* Adcli::Adconn.get_domain_controller #=> 'YOUR.DC.REALM.COM'
|
205
|
+
*
|
206
|
+
* Get the domain controller to use.
|
207
|
+
*
|
208
|
+
*/
|
209
|
+
static VALUE radconn_get_domain_controller (VALUE self) {
|
210
|
+
RUBY_ADCONN* ptr;
|
211
|
+
const char *domain_controller = NULL;
|
212
|
+
|
213
|
+
Data_Get_Struct (self ,RUBY_ADCONN, ptr);
|
214
|
+
|
215
|
+
domain_controller = adcli_conn_get_domain_controller (ptr->conn);
|
216
|
+
|
217
|
+
return rb_str_new_cstr (domain_controller);
|
218
|
+
}
|
219
|
+
|
220
|
+
/*
|
221
|
+
* call-seq:
|
222
|
+
* Adcli::Adconn.set_domain_controller('YOUR.DC.REALM.COM')
|
223
|
+
*
|
224
|
+
* Get the domain controller to use.
|
225
|
+
*
|
226
|
+
*/
|
227
|
+
static VALUE radconn_set_domain_controller (VALUE self, VALUE domain_controller) {
|
228
|
+
RUBY_ADCONN* ptr;
|
229
|
+
|
230
|
+
Check_Type(domain_controller, T_STRING);
|
231
|
+
|
232
|
+
char *c_domain_controller = StringValuePtr (domain_controller);
|
233
|
+
|
234
|
+
Data_Get_Struct (self, RUBY_ADCONN, ptr);
|
235
|
+
|
236
|
+
adcli_conn_set_domain_controller (ptr->conn, c_domain_controller);
|
237
|
+
|
238
|
+
return self;
|
239
|
+
}
|
240
|
+
|
241
|
+
/*
|
242
|
+
* call-seq:
|
243
|
+
* Adcli::Adconn.connect
|
244
|
+
*
|
245
|
+
* Connect to Active Directory and authenticate using the login username and password.
|
246
|
+
*
|
247
|
+
*/
|
248
|
+
static VALUE radconn_connect (VALUE self) {
|
249
|
+
RUBY_ADCONN* ptr;
|
250
|
+
adcli_result result;
|
251
|
+
|
252
|
+
Data_Get_Struct (self ,RUBY_ADCONN, ptr);
|
253
|
+
|
254
|
+
result = adcli_conn_connect (ptr->conn);
|
255
|
+
|
256
|
+
if (result != ADCLI_SUCCESS) {
|
257
|
+
rb_raise(c_adconn_exception, "%s", adcli_get_last_error());
|
258
|
+
}
|
259
|
+
|
260
|
+
return self;
|
261
|
+
}
|
262
|
+
|
263
|
+
void Init_AdConn()
|
264
|
+
{
|
265
|
+
c_adconn = rb_define_class_under (m_adcli, "AdConn", rb_cObject);
|
266
|
+
c_adconn_exception = rb_define_class_under (m_adcli, "Exception", rb_eStandardError);
|
267
|
+
|
268
|
+
// Allocate functions
|
269
|
+
rb_define_alloc_func (c_adconn, radconn_allocate);
|
270
|
+
|
271
|
+
// Initializers
|
272
|
+
rb_define_method (c_adconn, "initialize", radconn_initialize, 1);
|
273
|
+
|
274
|
+
// AdConn Methods
|
275
|
+
rb_define_method (c_adconn, "get_login_ccache_name", radconn_get_login_ccache_name, 0);
|
276
|
+
rb_define_method (c_adconn, "set_login_ccache_name", radconn_set_login_ccache_name, 1);
|
277
|
+
|
278
|
+
rb_define_method (c_adconn, "get_login_user", radconn_get_login_user, 0);
|
279
|
+
rb_define_method (c_adconn, "set_login_user", radconn_set_login_user, 1);
|
280
|
+
|
281
|
+
rb_define_method (c_adconn, "get_user_password", radconn_get_user_password, 0);
|
282
|
+
rb_define_method (c_adconn, "set_user_password", radconn_set_user_password, 1);
|
283
|
+
|
284
|
+
rb_define_method (c_adconn, "get_domain_realm", radconn_get_domain_realm, 0);
|
285
|
+
rb_define_method (c_adconn, "set_domain_realm", radconn_set_domain_realm, 1);
|
286
|
+
|
287
|
+
rb_define_method(c_adconn, "get_domain_controller", radconn_get_domain_controller, 0);
|
288
|
+
rb_define_method(c_adconn, "set_domain_controller", radconn_set_domain_controller, 1);
|
289
|
+
|
290
|
+
rb_define_method(c_adconn, "connect", radconn_connect, 0);
|
291
|
+
}
|