import os
import sys
import time
+import ldb
import samba.param
+from samba import _glue
+from samba._ldb import Ldb as _Ldb
def source_tree_topdir():
return True
-import ldb
-from samba._ldb import Ldb as _Ldb
-
-
class Ldb(_Ldb):
"""Simple Samba-specific LDB subclass that takes care
of setting up the modules dir, credentials pointers, etc.
# TODO set debug
def msg(l, text):
- print text
+ print(text)
#self.set_debug(msg)
self.set_utf8_casefold()
if nosync_p is not None and nosync_p:
flags |= ldb.FLG_NOSYNC
- self.set_create_perms(0600)
+ self.set_create_perms(0o600)
if url is not None:
self.connect(url, flags, options)
try:
res = self.search(base=dn, scope=ldb.SCOPE_SUBTREE, attrs=[],
expression="(|(objectclass=user)(objectclass=computer))")
- except ldb.LdbError, (errno, _):
+ except ldb.LdbError as error:
+ (errno, estr) = error.args
if errno == ldb.ERR_NO_SUCH_OBJECT:
# Ignore no such object errors
return
try:
for msg in res:
self.delete(msg.dn, ["relax:0"])
- except ldb.LdbError, (errno, _):
+ except ldb.LdbError as error:
+ (errno, estr) = error.args
if errno != ldb.ERR_NO_SUCH_OBJECT:
# Ignore no such object errors
raise
[], controls=["show_deleted:0", "show_recycled:0"]):
try:
self.delete(msg.dn, ["relax:0"])
- except ldb.LdbError, (errno, _):
+ except ldb.LdbError as error:
+ (errno, estr) = error.args
if errno != ldb.ERR_NO_SUCH_OBJECT:
# Ignore no such object errors
raise
"@OPTIONS", "@PARTITION", "@KLUDGEACL"]:
try:
self.delete(attr, ["relax:0"])
- except ldb.LdbError, (errno, _):
+ except ldb.LdbError as error:
+ (errno, estr) = error.args
if errno != ldb.ERR_NO_SUCH_OBJECT:
# Ignore missing dn errors
raise
for attr in ["@INDEXLIST", "@ATTRIBUTES"]:
try:
self.delete(attr, ["relax:0"])
- except ldb.LdbError, (errno, _):
+ except ldb.LdbError as error:
+ (errno, estr) = error.args
if errno != ldb.ERR_NO_SUCH_OBJECT:
# Ignore missing dn errors
raise
def current_unix_time():
return int(time.time())
-import _glue
+def string_to_byte_array(string):
+ blob = [0] * len(string)
+
+ for i in range(len(string)):
+ blob[i] = ord(string[i])
+
+ return blob
+
+def arcfour_encrypt(key, data):
+ from samba.crypto import arcfour_crypt_blob
+ return arcfour_crypt_blob(data, key)
+
version = _glue.version
interface_ips = _glue.interface_ips
set_debug_level = _glue.set_debug_level
nttime2unix = _glue.nttime2unix
unix2nttime = _glue.unix2nttime
generate_random_password = _glue.generate_random_password
+generate_random_machine_password = _glue.generate_random_machine_password
strcasecmp_m = _glue.strcasecmp_m
strstr_m = _glue.strstr_m
is_ntvfs_fileserver_built = _glue.is_ntvfs_fileserver_built
+is_heimdal_built = _glue.is_heimdal_built
+
+NTSTATUSError = _glue.NTSTATUSError
+HRESULTError = _glue.HRESULTError
+WERRORError = _glue.WERRORError
+DsExtendedError = _glue.DsExtendedError