radcli 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2dfdb7ef72454b16327f0043dbecca55c855634e
4
+ data.tar.gz: 8df85fb65856d1700f59a8ae98285521af0498ab
5
+ SHA512:
6
+ metadata.gz: 86bc89bee5ab9d9e98f710a2ec835b70fd537f3e47f7be38fd76fa50267df698a4e1f87a9203181b58a2a2a2c138f5782aba3b0f45b1eb4d83be9266ac6d6986
7
+ data.tar.gz: 2767894076c47ae95edcad05a1accbfd93517e36f08812bf579acd732450bfa9f772531c3e147975e36a803b3baac08246bcc814c55077cb3203ba3ae55b3275
data/CHANGES ADDED
File without changes
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ The Artistic License 2.0
2
+
3
+ Copyright (c) 2000-2006, The Perl Foundation.
4
+
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ This license establishes the terms under which a given free software
11
+ Package may be copied, modified, distributed, and/or redistributed.
12
+ The intent is that the Copyright Holder maintains some artistic
13
+ control over the development of that Package while still keeping the
14
+ Package available as open source and free software.
15
+
16
+ You are always permitted to make arrangements wholly outside of this
17
+ license directly with the Copyright Holder of a given Package. If the
18
+ terms of this license do not permit the full use that you propose to
19
+ make of the Package, you should contact the Copyright Holder and seek
20
+ a different licensing arrangement.
21
+
22
+ Definitions
23
+
24
+ "Copyright Holder" means the individual(s) or organization(s)
25
+ named in the copyright notice for the entire Package.
26
+
27
+ "Contributor" means any party that has contributed code or other
28
+ material to the Package, in accordance with the Copyright Holder's
29
+ procedures.
30
+
31
+ "You" and "your" means any person who would like to copy,
32
+ distribute, or modify the Package.
33
+
34
+ "Package" means the collection of files distributed by the
35
+ Copyright Holder, and derivatives of that collection and/or of
36
+ those files. A given Package may consist of either the Standard
37
+ Version, or a Modified Version.
38
+
39
+ "Distribute" means providing a copy of the Package or making it
40
+ accessible to anyone else, or in the case of a company or
41
+ organization, to others outside of your company or organization.
42
+
43
+ "Distributor Fee" means any fee that you charge for Distributing
44
+ this Package or providing support for this Package to another
45
+ party. It does not mean licensing fees.
46
+
47
+ "Standard Version" refers to the Package if it has not been
48
+ modified, or has been modified only in ways explicitly requested
49
+ by the Copyright Holder.
50
+
51
+ "Modified Version" means the Package, if it has been changed, and
52
+ such changes were not explicitly requested by the Copyright
53
+ Holder.
54
+
55
+ "Original License" means this Artistic License as Distributed with
56
+ the Standard Version of the Package, in its current version or as
57
+ it may be modified by The Perl Foundation in the future.
58
+
59
+ "Source" form means the source code, documentation source, and
60
+ configuration files for the Package.
61
+
62
+ "Compiled" form means the compiled bytecode, object code, binary,
63
+ or any other form resulting from mechanical transformation or
64
+ translation of the Source form.
65
+
66
+
67
+ Permission for Use and Modification Without Distribution
68
+
69
+ (1) You are permitted to use the Standard Version and create and use
70
+ Modified Versions for any purpose without restriction, provided that
71
+ you do not Distribute the Modified Version.
72
+
73
+
74
+ Permissions for Redistribution of the Standard Version
75
+
76
+ (2) You may Distribute verbatim copies of the Source form of the
77
+ Standard Version of this Package in any medium without restriction,
78
+ either gratis or for a Distributor Fee, provided that you duplicate
79
+ all of the original copyright notices and associated disclaimers. At
80
+ your discretion, such verbatim copies may or may not include a
81
+ Compiled form of the Package.
82
+
83
+ (3) You may apply any bug fixes, portability changes, and other
84
+ modifications made available from the Copyright Holder. The resulting
85
+ Package will still be considered the Standard Version, and as such
86
+ will be subject to the Original License.
87
+
88
+
89
+ Distribution of Modified Versions of the Package as Source
90
+
91
+ (4) You may Distribute your Modified Version as Source (either gratis
92
+ or for a Distributor Fee, and with or without a Compiled form of the
93
+ Modified Version) provided that you clearly document how it differs
94
+ from the Standard Version, including, but not limited to, documenting
95
+ any non-standard features, executables, or modules, and provided that
96
+ you do at least ONE of the following:
97
+
98
+ (a) make the Modified Version available to the Copyright Holder
99
+ of the Standard Version, under the Original License, so that the
100
+ Copyright Holder may include your modifications in the Standard
101
+ Version.
102
+
103
+ (b) ensure that installation of your Modified Version does not
104
+ prevent the user installing or running the Standard Version. In
105
+ addition, the Modified Version must bear a name that is different
106
+ from the name of the Standard Version.
107
+
108
+ (c) allow anyone who receives a copy of the Modified Version to
109
+ make the Source form of the Modified Version available to others
110
+ under
111
+
112
+ (i) the Original License or
113
+
114
+ (ii) a license that permits the licensee to freely copy,
115
+ modify and redistribute the Modified Version using the same
116
+ licensing terms that apply to the copy that the licensee
117
+ received, and requires that the Source form of the Modified
118
+ Version, and of any works derived from it, be made freely
119
+ available in that license fees are prohibited but Distributor
120
+ Fees are allowed.
121
+
122
+
123
+ Distribution of Compiled Forms of the Standard Version
124
+ or Modified Versions without the Source
125
+
126
+ (5) You may Distribute Compiled forms of the Standard Version without
127
+ the Source, provided that you include complete instructions on how to
128
+ get the Source of the Standard Version. Such instructions must be
129
+ valid at the time of your distribution. If these instructions, at any
130
+ time while you are carrying out such distribution, become invalid, you
131
+ must provide new instructions on demand or cease further distribution.
132
+ If you provide valid instructions or cease distribution within thirty
133
+ days after you become aware that the instructions are invalid, then
134
+ you do not forfeit any of your rights under this license.
135
+
136
+ (6) You may Distribute a Modified Version in Compiled form without
137
+ the Source, provided that you comply with Section 4 with respect to
138
+ the Source of the Modified Version.
139
+
140
+
141
+ Aggregating or Linking the Package
142
+
143
+ (7) You may aggregate the Package (either the Standard Version or
144
+ Modified Version) with other packages and Distribute the resulting
145
+ aggregation provided that you do not charge a licensing fee for the
146
+ Package. Distributor Fees are permitted, and licensing fees for other
147
+ components in the aggregation are permitted. The terms of this license
148
+ apply to the use and Distribution of the Standard or Modified Versions
149
+ as included in the aggregation.
150
+
151
+ (8) You are permitted to link Modified and Standard Versions with
152
+ other works, to embed the Package in a larger work of your own, or to
153
+ build stand-alone binary or bytecode versions of applications that
154
+ include the Package, and Distribute the result without restriction,
155
+ provided the result does not expose a direct interface to the Package.
156
+
157
+
158
+ Items That are Not Considered Part of a Modified Version
159
+
160
+ (9) Works (including, but not limited to, modules and scripts) that
161
+ merely extend or make use of the Package, do not, by themselves, cause
162
+ the Package to be a Modified Version. In addition, such works are not
163
+ considered parts of the Package itself, and are not subject to the
164
+ terms of this license.
165
+
166
+
167
+ General Provisions
168
+
169
+ (10) Any use, modification, and distribution of the Standard or
170
+ Modified Versions is governed by this Artistic License. By using,
171
+ modifying or distributing the Package, you accept this license. Do not
172
+ use, modify, or distribute the Package, if you do not accept this
173
+ license.
174
+
175
+ (11) If your Modified Version has been derived from a Modified
176
+ Version made by someone other than you, you are nevertheless required
177
+ to ensure that your Modified Version complies with the requirements of
178
+ this license.
179
+
180
+ (12) This license does not grant you the right to use any trademark,
181
+ service mark, tradename, or logo of the Copyright Holder.
182
+
183
+ (13) This license includes the non-exclusive, worldwide,
184
+ free-of-charge patent license to make, have made, use, offer to sell,
185
+ sell, import and otherwise transfer the Package with respect to any
186
+ patent claims licensable by the Copyright Holder that are necessarily
187
+ infringed by the Package. If you institute patent litigation
188
+ (including a cross-claim or counterclaim) against any party alleging
189
+ that the Package constitutes direct or contributory patent
190
+ infringement, then this Artistic License to you shall terminate on the
191
+ date that such litigation is filed.
192
+
193
+ (14) Disclaimer of Warranty:
194
+ THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS
195
+ IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED
196
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
197
+ NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL
198
+ LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL
199
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
200
+ DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF
201
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/MANIFEST ADDED
@@ -0,0 +1,13 @@
1
+ CHANGES
2
+ radcli.gemspec
3
+ MANIFEST
4
+ Rakefile
5
+ README
6
+ ext/adutil.h
7
+ ext/adconn.h
8
+ ext/adenroll.h
9
+ ext/radconn.c
10
+ ext/radenroll.c
11
+ ext/radcli.c
12
+ ext/radcli.h
13
+ test/test_adcli.rb
data/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # Description
2
+ The radcli library provides a Ruby interface for performing actions on a Active Directory domain using the realmd/adcli tool.
3
+ (adcli: https://www.freedesktop.org/software/realmd/adcli/devel-building.html)
4
+
5
+ # Installation
6
+
7
+
8
+ ### Prerequisites (Ubuntu)
9
+ ```
10
+ sudo apt-get install ruby gem ruby-dev
11
+ sudo gem install rake bundler rakecompiler rspec
12
+ sudo apt-get install automake autoconf xmlto xsltproc libkrb5-dev libldap2-dev libsasl2-dev
13
+ ```
14
+
15
+ ### Prerequisites (Fedora)
16
+ ```
17
+ sudo yum ruby gem ruby-devel
18
+ gem install rake bundler rakecompiler rspec
19
+ sudo yum install automake autoconf xmlto xsltproc krb5-devel openldap-devel cyrus-sasl-devel
20
+ ```
21
+
22
+ ### Building
23
+ ```
24
+ git clone https://github.com/martencassel/radcli
25
+ cd radcli
26
+ rake build
27
+ gem install pkg/radcli-0.0.1.gem
28
+ ```
29
+
30
+ # Synposis
31
+
32
+ ### Connect using username/password
33
+ ```ruby
34
+ require 'radcli'
35
+
36
+ adconn = Adcli::AdConn.new("example.com")
37
+ adconn.set_domain_realm("EXAMPLE.COM")
38
+ adconn.set_domain_controller("dc.example.com")
39
+
40
+ adconn.set_login_user("Administrator")
41
+ adconn.set_user_password("password")
42
+
43
+ res = adconn.connect
44
+ ```
45
+
46
+ ### or connect using local credentials cache
47
+ ```ruby
48
+ require 'radcli'
49
+ require "rkerberos"
50
+
51
+ # Kinit using principal name and keytab.
52
+ principal = "Administrator"
53
+ keytab file over an unsecured network.
54
+ keytab="/etc/foreman-proxy/ad.keytab"
55
+ krb5 = Kerberos::Krb5.new
56
+ ccache = Kerberos::Krb5::CredentialsCache.new
57
+ krb5.get_init_creds_keytab principal, keytab, nil, ccache
58
+
59
+ # Connect
60
+
61
+ adconn = Adcli::AdConn.new("example.com")
62
+ adconn.set_domain_realm("EXAMPLE.COM")
63
+ adconn.set_domain_controller("dc.example.com")
64
+
65
+ adconn.set_login_ccache_name("")
66
+
67
+ res = adconn.connect
68
+ ```
69
+
70
+ ### Join
71
+ ```ruby
72
+
73
+ enroll = Adcli::AdEnroll.new(adconn)
74
+ enroll.set_computer_name("server")
75
+ enroll.set_host_fqdn("server.example.com")
76
+ enroll.set_computer_password("password")
77
+
78
+ enroll.join()
79
+ ```
80
+
81
+ ### Reset Password
82
+ ```ruby
83
+
84
+ enroll = Adcli::AdEnroll.new(adconn)
85
+ enroll.set_computer_name("server")
86
+ enroll.set_computer_password("newpass")
87
+
88
+ enroll.password()
89
+
90
+ ```
91
+
92
+ ### Delete
93
+ ```ruby
94
+
95
+ enroll = Adcli::AdEnroll.new(adconn)
96
+ enroll.set_computer_name("server")
97
+
98
+ enroll.delete()
99
+ ```
100
+
101
+ # Notes
102
+ For a testing environment you need the following:
103
+
104
+ * A windows domain controller and a connected linux server.
105
+ * The linux server must be able to resolve domain names from the domains dns server.
106
+
107
+ # Authors
108
+ * Mårten Cassel
109
+
data/Rakefile ADDED
@@ -0,0 +1,65 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/extensiontask'
4
+ require 'rake/clean'
5
+ require 'rbconfig'
6
+ require 'rubygems/package'
7
+ require 'bundler/gem_tasks'
8
+
9
+ CLEAN.include(
10
+ "ext/radcli/*.o",
11
+ "ext/radcli/*.bundle",
12
+ "**/tmp"
13
+ )
14
+
15
+ CLOBBER.include(
16
+ "ext/radcli/Makefile",
17
+ "pkg"
18
+ )
19
+
20
+ BUILD_DIR = 'build'
21
+
22
+ def gem_spec
23
+ @gem_spec ||= Gem::Specification.load('radcli.gemspec')
24
+ end
25
+
26
+ Gem::PackageTask.new(gem_spec) do |pkg|
27
+ pkg.need_zip = true
28
+ pkg.need_tar = true
29
+ end
30
+
31
+ Rake::ExtensionTask.new("radcli", gem_spec) do |ext|
32
+ ext.ext_dir = './ext/radcli'
33
+ ext.lib_dir = './ext/lib'
34
+ ext.config_script = "extconf.rb"
35
+ end
36
+
37
+ namespace 'test' do
38
+
39
+ Rake::TestTask.new('all') do |t|
40
+ task :all => [:clean, :compile]
41
+ t.libs << 'ext/radcli'
42
+ t.warning = true
43
+ t.verbose = true
44
+ end
45
+
46
+ Rake::TestTask.new('adconn') do |t|
47
+ task :context => [:clean, :compile]
48
+ t.libs << 'ext'
49
+ t.test_files = FileList['test/test_radconn.rb']
50
+ t.warning = true
51
+ t.verbose = true
52
+ end
53
+
54
+ Rake::TestTask.new('adenroll') do |t|
55
+ task :context => [:clean, :compile]
56
+ t.libs << 'ext'
57
+ t.test_files = FileList['test/test_radenroll.rb']
58
+ t.warning = true
59
+ t.verbose = true
60
+ end
61
+ end
62
+
63
+ task :build => [:clean, :compile]
64
+
65
+ task :default => ['test:all']
data/build_adcli.sh ADDED
@@ -0,0 +1,6 @@
1
+ #!/bin/sh
2
+ yum -y groupinstall 'Development Tools' && sudo yum -y install automake autoconf xmlto xsltproc krb5-devel openldap-devel cyrus-sasl-devel
3
+ rm -rf ./adcli && git clone http://cgit.freedesktop.org/realmd/adcli/
4
+ cd ./adcli && ./autogen.sh --prefix=/usr --sysconfdir=/etc && make && mv ./library/.libs/libadcli.a ../ext/lib/
5
+ git add -f ./ext/lib/libadcli.a
6
+ rm -rf ./adcli
Binary file
@@ -0,0 +1,147 @@
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 ADCONN_H_
25
+ #define ADCONN_H_
26
+
27
+ #include "adutil.h"
28
+
29
+ #include <krb5/krb5.h>
30
+ #include <ldap.h>
31
+
32
+ typedef enum {
33
+ ADCLI_LOGIN_UNKNOWN = 0,
34
+ ADCLI_LOGIN_COMPUTER_ACCOUNT = 1 << 1,
35
+ ADCLI_LOGIN_USER_ACCOUNT = 1 << 2,
36
+ } adcli_login_type;
37
+
38
+ #define ADCLI_CAP_OID "1.2.840.113556.1.4.800"
39
+ #define ADCLI_CAP_LDAP_INTEG_OID "1.2.840.113556.1.4.1791"
40
+ #define ADCLI_CAP_V51_OID "1.2.840.113556.1.4.1670"
41
+ #define ADCLI_CAP_ADAM_DIGEST "1.2.840.113556.1.4.1880"
42
+ #define ADCLI_CAP_ADAM_OID "1.2.840.113556.1.4.1851"
43
+ #define ADCLI_CAP_PARTIAL_SECRETS_OID "1.2.840.113556.1.4.1920"
44
+ #define ADCLI_CAP_V60_OID "1.2.840.113556.1.4.1935"
45
+ #define ADCLI_CAP_V61_R2_OID "1.2.840.113556.1.4.2080"
46
+ #define ADCLI_CAP_W8_OID "1.2.840.113556.1.4.2237"
47
+
48
+ typedef char * (* adcli_password_func) (adcli_login_type type,
49
+ const char *name,
50
+ int flags,
51
+ void *data);
52
+
53
+ typedef void (* adcli_destroy_func) (void *data);
54
+
55
+ typedef struct _adcli_conn_ctx adcli_conn;
56
+
57
+ adcli_result adcli_conn_discover (adcli_conn *conn);
58
+
59
+ adcli_result adcli_conn_connect (adcli_conn *conn);
60
+
61
+ adcli_conn * adcli_conn_new (const char *domain);
62
+
63
+ adcli_conn * adcli_conn_ref (adcli_conn *conn);
64
+
65
+ void adcli_conn_unref (adcli_conn *conn);
66
+
67
+ void adcli_conn_set_password_func (adcli_conn *conn,
68
+ adcli_password_func password_func,
69
+ void *data,
70
+ adcli_destroy_func destroy_data);
71
+
72
+ const char * adcli_conn_get_host_fqdn (adcli_conn *conn);
73
+
74
+ void adcli_conn_set_host_fqdn (adcli_conn *conn,
75
+ const char *value);
76
+
77
+ const char * adcli_conn_get_domain_name (adcli_conn *conn);
78
+
79
+ void adcli_conn_set_domain_name (adcli_conn *conn,
80
+ const char *value);
81
+
82
+ const char * adcli_conn_get_domain_realm (adcli_conn *conn);
83
+
84
+ void adcli_conn_set_domain_realm (adcli_conn *conn,
85
+ const char *value);
86
+
87
+ const char * adcli_conn_get_domain_controller (adcli_conn *conn);
88
+
89
+ void adcli_conn_set_domain_controller (adcli_conn *conn,
90
+ const char *value);
91
+
92
+ const char * adcli_conn_get_domain_short (adcli_conn *conn);
93
+
94
+ LDAP * adcli_conn_get_ldap_connection (adcli_conn *conn);
95
+
96
+ krb5_context adcli_conn_get_krb5_context (adcli_conn *conn);
97
+
98
+ const char * adcli_conn_get_computer_name (adcli_conn *conn);
99
+
100
+ void adcli_conn_set_computer_name (adcli_conn *conn,
101
+ const char *value);
102
+
103
+ const char * adcli_conn_get_computer_password (adcli_conn *conn);
104
+
105
+ void adcli_conn_set_computer_password (adcli_conn *conn,
106
+ const char *password);
107
+
108
+ const char * adcli_conn_get_login_user (adcli_conn *conn);
109
+
110
+ void adcli_conn_set_login_user (adcli_conn *conn,
111
+ const char *value);
112
+
113
+ const char * adcli_conn_get_user_password (adcli_conn *conn);
114
+
115
+ void adcli_conn_set_user_password (adcli_conn *conn,
116
+ const char *value);
117
+
118
+ adcli_login_type adcli_conn_get_login_type (adcli_conn *conn);
119
+
120
+ adcli_login_type adcli_conn_get_allowed_login_types (adcli_conn *conn);
121
+
122
+ void adcli_conn_set_allowed_login_types (adcli_conn *conn,
123
+ adcli_login_type types);
124
+
125
+ krb5_ccache adcli_conn_get_login_ccache (adcli_conn *conn);
126
+
127
+ const char * adcli_conn_get_login_ccache_name (adcli_conn *conn);
128
+
129
+ void adcli_conn_set_login_ccache_name (adcli_conn *conn,
130
+ const char *ccname);
131
+
132
+ const char * adcli_conn_get_login_keytab_name (adcli_conn *conn);
133
+
134
+ void adcli_conn_set_login_keytab_name (adcli_conn *conn,
135
+ const char *ktname);
136
+
137
+ const char * adcli_conn_get_default_naming_context (adcli_conn *conn);
138
+
139
+ const char * adcli_conn_get_krb5_conf_dir (adcli_conn *conn);
140
+
141
+ void adcli_conn_set_krb5_conf_dir (adcli_conn *conn,
142
+ const char *value);
143
+
144
+ int adcli_conn_server_has_capability (adcli_conn *conn,
145
+ const char *capability);
146
+
147
+ #endif /* ADCONN_H_ */