3 # Unix SMB/CIFS implementation.
4 # Copyright (C) Volker Lendecke 2008
6 # Extract our own machine pw from secrets.ldb
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.
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.
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/>.
22 import samba.param as param, ldb, sys, getopt
24 optlist, args = getopt.getopt(sys.argv[1:], "s:")
26 conf = param.LoadParm()
32 raise(v + " not found")
39 secrets.connect(conf.get("private dir") + "/secrets.ldb")
41 search = "(&(objectclass=primaryDomain)(samaccountname=" + \
42 conf.get("netbios name") + "$))"
44 msg = secrets.search(expression=search, attrs=['secret'])
45 print(msg[0]['secret'][0])