3 # Unix SMB/CIFS implementation.
4 # Vampire a remote domain
5 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 from net
import libnet
23 import samba
.getopt
as options
25 from auth
import system_session
28 parser
= optparse
.OptionParser("vampire [options] <domain>")
29 parser
.add_option_group(options
.SambaOptions(parser
))
30 parser
.add_option_group(options
.VersionOptions(parser
))
31 credopts
= options
.CredentialsOptions(parser
)
32 parser
.add_option_group(credopts
)
34 opts
, args
= parser
.parse_args()
40 def vampire(domain
, session_info
, credentials
, lp
):
41 ctx
= libnet(lp_ctx
=lp
)
42 ctx
.cred
= credentials
43 machine_creds
= Credentials();
44 machine_creds
.set_domain(domain
);
45 if not machine_creds
.set_machine_account():
46 raise Exception("Failed to access domain join information!")
47 ctx
.samsync_ldb(vampire_ctx
, machine_creds
=machine_creds
,
48 session_info
=session_info
)
52 lp
.load(opts
.configfile
)
53 vampire(args
[0], session_info
=system_session(),
54 credentials
=credopts
.get_credentials(), lp
=lp
)