"""Convenience functions for using the SAM."""
+import dsdb
import samba
import glue
import ldb
def __init__(self, url=None, lp=None, modules_dir=None, session_info=None,
credentials=None, flags=0, options=None):
- """Opens the SAM Database
- For parameter meanings see the super class (samba.Ldb)
- """
-
self.lp = lp
if url is None:
url = lp.get("sam database")
""" % (user_dn)
self.modify_ldif(mod)
- def newuser(self, username, unixname, password, force_password_change_at_next_login_req=False):
+ def newuser(self, username, unixname, password,
+ force_password_change_at_next_login_req=False):
"""Adds a new user
Note: This call adds also the ID mapping for winbind; therefore it works
raise
self.transaction_commit()
- def setpassword(self, filter, password, force_password_change_at_next_login_req=False):
+ def setpassword(self, filter, password, force_change_at_next_login=False):
"""Sets the password for a user
Note: This call uses the "userPassword" attribute to set the password.
:param filter: LDAP filter to find the user (eg samccountname=name)
:param password: Password for the user
- :param force_password_change_at_next_login_req: Force password change
+ :param force_change_at_next_login: Force password change
"""
self.transaction_start()
try:
self.modify_ldif(setpw)
- if force_password_change_at_next_login_req:
+ if force_change_at_next_login:
self.force_password_change_at_next_login(
"(dn=" + str(user_dn) + ")")
self.transaction_cancel()
raise
self.transaction_commit()
+
+ def set_domain_sid(self, sid):
+ """Change the domain SID used by this LDB.
+
+ :param sid: The new domain sid to use.
+ """
+ dsdb.samdb_set_domain_sid(self, sid)
+
+ def get_domain_sid(self):
+ """Read the domain SID used by this LDB.
+
+ """
+ dsdb.samdb_get_domain_sid(self)
+
+ def set_invocation_id(self, invocation_id):
+ """Set the invocation id for this SamDB handle.
+
+ :param invocation_id: GUID of the invocation id.
+ """
+ dsdb.dsdb_set_ntds_invocation_id(self, invocation_id)
+
+ def get_invocation_id(self):
+ "Get the invocation_id id"
+ return dsdb.samdb_ntds_invocation_id(self)
+
+ invocation_id = property(get_invocation_id, set_invocation_id)
+
+ domain_sid = property(get_domain_sid, set_domain_sid)
+
+ def get_ntds_GUID(self):
+ "Get the NTDS objectGUID"
+ return dsdb.samdb_ntds_objectGUID(self)
+
+ def server_site_name(self):
+ "Get the server site name"
+ return dsdb.samdb_server_site_name(self)