s.s.SamDB(samba.Ldb) : class documentation

Part of samba.samdb View In Hierarchy

The SAM database.
Method __init__ Opens a Samba Ldb file.
Method connect connect to the database
Method am_rodc return True if we are an RODC
Method am_pdc return True if we are an PDC emulator
Method domain_dn return the domain DN
Method disable_account Disables an account
Method enable_account Enables an account
Method toggle_userAccountFlags toggle_userAccountFlags
Method force_password_change_at_next_login Forces a password change at next login
Method newgroup Adds a new group with additional parameters
Method deletegroup Deletes a group
Method add_remove_group_members Adds or removes group members
Method newuser Adds a new user with additional parameters
Method deleteuser Deletes a user
Method setpassword Sets the password for a user
Method setexpiry Sets the account expiry for a user
Method set_domain_sid Change the domain SID used by this LDB.
Method get_domain_sid Read the domain SID used by this LDB.
Method set_invocation_id Set the invocation id for this SamDB handle.
Method get_invocation_id Get the invocation_id id
Method get_oid_from_attid Undocumented
Method get_attid_from_lDAPDisplayName return the attribute ID for a LDAP attribute as an integer as found in DRSUAPI
Method get_syntax_oid_from_lDAPDisplayName return the syntax OID for a LDAP attribute as a string
Method get_systemFlags_from_lDAPDisplayName return the systemFlags for a LDAP attribute as a integer
Method get_linkId_from_lDAPDisplayName return the linkID for a LDAP attribute as a integer
Method get_lDAPDisplayName_by_attid return the lDAPDisplayName from an integer DRS attribute ID
Method get_backlink_from_lDAPDisplayName return the attribute name of the corresponding backlink from the name of a forward link attribute. If there is no backlink return None
Method set_ntds_settings_dn Set the NTDS Settings DN, as would be returned on the dsServiceName rootDSE attribute.
Method get_ntds_GUID Get the NTDS objectGUID
Method server_site_name Get the server site name
Method host_dns_name return the DNS name of this host
Method domain_dns_name return the DNS name of the domain root
Method forest_dns_name return the DNS name of the forest root
Method load_partition_usn Undocumented
Method set_schema Undocumented
Method set_schema_from_ldb Undocumented
Method dsdb_DsReplicaAttribute convert a list of attribute values to a DRSUAPI DsReplicaAttribute
Method dsdb_normalise_attributes normalise a list of attribute values
Method get_attribute_from_attid Get from an attid the associated attribute
Method get_attribute_replmetadata_version Get the version field trom the replPropertyMetaData for the given field
Method set_attribute_replmetadata_version Undocumented
Method write_prefixes_from_schema Undocumented
Method get_partitions_dn Undocumented
Method set_minPwdAge Undocumented
Method get_minPwdAge Undocumented
Method set_minPwdLength Undocumented
Method get_minPwdLength Undocumented
Method set_pwdProperties Undocumented
Method get_pwdProperties Undocumented
Method set_dsheuristics Undocumented
Method get_dsheuristics Undocumented
Method create_ou No summary
Method sequence_number Returns the value of the sequence number according to the requested type :param seq_type: type of sequence number
Method get_dsServiceName get the NTDS DN from the rootDSE
Method get_serverName get the server DN from the rootDSE
Method _populate_oid_attid Populate the hash hash_oid_name.

Inherited from Ldb:

Method searchone Search for one attribute as a string.
Method erase_users_computers Erases user and computer objects from our AD.
Method erase_except_schema_controlled Erase this ldb.
Method erase Erase this ldb, removing all records.
Method load_ldif_file_add Load a LDIF file.
Method add_ldif Add data based on a LDIF string.
Method modify_ldif Modify database based on a LDIF string.
def __init__(self, url=None, lp=None, modules_dir=None, session_info=None, credentials=None, flags=0, options=None, global_schema=True, auto_connect=True, am_rodc=None):
Opens a Samba Ldb file.

This is different from a regular Ldb file in that the Samba-specific modules-dir is used by default and that credentials and session_info can be passed through (required by some modules).

ParametersurlOptional LDB URL to open
lpOptional loadparm object
modules_dirOptional modules directory
session_infoOptional session information
credentialsOptional credentials, defaults to anonymous.
flagsOptional LDB flags
optionsAdditional options (optional)
def connect(self, url=None, flags=0, options=None):
connect to the database
def am_rodc(self):
return True if we are an RODC
def am_pdc(self):
return True if we are an PDC emulator
def domain_dn(self):
return the domain DN
def disable_account(self, search_filter):
Disables an account
Parameterssearch_filterLDAP filter to find the user (eg samccountname=name)
def enable_account(self, search_filter):
Enables an account
Parameterssearch_filterLDAP filter to find the user (eg samccountname=name)
def toggle_userAccountFlags(self, search_filter, flags, flags_str=None, on=True, strict=False):
toggle_userAccountFlags
Parameterssearch_filterLDAP filter to find the user (eg samccountname=name)
Unknown Field: flagssamba.dsdb.UF_* flags
Unknown Field: onon=True (default) => set, on=False => unset
Unknown Field: strictstrict=False (default) ignore if no action is needed strict=True raises an Exception if...
def force_password_change_at_next_login(self, search_filter):
Forces a password change at next login
Parameterssearch_filterLDAP filter to find the user (eg samccountname=name)
def newgroup(self, groupname, groupou=None, grouptype=None, description=None, mailaddress=None, notes=None, sd=None):
Adds a new group with additional parameters
ParametersgroupnameName of the new group
grouptypeType of the new group
descriptionDescription of the new group
mailaddressEmail address of the new group
notesNotes of the new group
sdsecurity descriptor of the object
def deletegroup(self, groupname):
Deletes a group
ParametersgroupnameName of the target group
def add_remove_group_members(self, groupname, listofmembers, add_members_operation=True):
Adds or removes group members
ParametersgroupnameName of the target group
listofmembersComma-separated list of group members
add_members_operationDefines if its an add or remove operation
def newuser(self, username, password, force_password_change_at_next_login_req=False, useusernameascn=False, userou=None, surname=None, givenname=None, initials=None, profilepath=None, scriptpath=None, homedrive=None, homedirectory=None, jobtitle=None, department=None, company=None, description=None, mailaddress=None, internetaddress=None, telephonenumber=None, physicaldeliveryoffice=None, sd=None, setpassword=True):
Adds a new user with additional parameters
ParametersusernameName of the new user
passwordPassword for the new user
force_password_change_at_next_login_reqForce password change
useusernameascnUse username as cn rather that firstname + initials + lastname
userouObject container (without domainDN postfix) for new user
surnameSurname of the new user
givennameFirst name of the new user
initialsInitials of the new user
profilepathProfile path of the new user
scriptpathLogon script path of the new user
homedriveHome drive of the new user
homedirectoryHome directory of the new user
jobtitleJob title of the new user
departmentDepartment of the new user
companyCompany of the new user
descriptionof the new user
mailaddressEmail address of the new user
internetaddressHome page of the new user
telephonenumberPhone number of the new user
physicaldeliveryofficeOffice location of the new user
sdsecurity descriptor of the object
setpasswordoptionally disable password reset
def deleteuser(self, username):
Deletes a user
ParametersusernameName of the target user
def setpassword(self, search_filter, password, force_change_at_next_login=False, username=None):
Sets the password for a user
Parameterssearch_filterLDAP filter to find the user (eg samccountname=name)
passwordPassword for the user
force_change_at_next_loginForce password change
def setexpiry(self, search_filter, expiry_seconds, no_expiry_req=False):
Sets the account expiry for a user
Parameterssearch_filterLDAP filter to find the user (eg samaccountname=name)
expiry_secondsexpiry time from now in seconds
no_expiry_reqif set, then don't expire password
def set_domain_sid(self, sid):
Change the domain SID used by this LDB.
ParameterssidThe new domain sid to use.
def get_domain_sid(self):
Read the domain SID used by this LDB.
def set_invocation_id(self, invocation_id):
Set the invocation id for this SamDB handle.
Parametersinvocation_idGUID of the invocation id.
def get_invocation_id(self):
Get the invocation_id id
def get_oid_from_attid(self, attid):
Undocumented
def get_attid_from_lDAPDisplayName(self, ldap_display_name, is_schema_nc=False):
return the attribute ID for a LDAP attribute as an integer as found in DRSUAPI
def get_syntax_oid_from_lDAPDisplayName(self, ldap_display_name):
return the syntax OID for a LDAP attribute as a string
def get_systemFlags_from_lDAPDisplayName(self, ldap_display_name):
return the systemFlags for a LDAP attribute as a integer
def get_linkId_from_lDAPDisplayName(self, ldap_display_name):
return the linkID for a LDAP attribute as a integer
def get_lDAPDisplayName_by_attid(self, attid):
return the lDAPDisplayName from an integer DRS attribute ID
def get_backlink_from_lDAPDisplayName(self, ldap_display_name):
return the attribute name of the corresponding backlink from the name of a forward link attribute. If there is no backlink return None
def set_ntds_settings_dn(self, ntds_settings_dn):
Set the NTDS Settings DN, as would be returned on the dsServiceName rootDSE attribute.

This allows the DN to be set before the database fully exists

Parametersntds_settings_dnThe new DN to use
def get_ntds_GUID(self):
Get the NTDS objectGUID
def server_site_name(self):
Get the server site name
def host_dns_name(self):
return the DNS name of this host
def domain_dns_name(self):
return the DNS name of the domain root
def forest_dns_name(self):
return the DNS name of the forest root
def load_partition_usn(self, base_dn):
Undocumented
def set_schema(self, schema):
Undocumented
def set_schema_from_ldb(self, ldb_conn):
Undocumented
def dsdb_DsReplicaAttribute(self, ldb, ldap_display_name, ldif_elements):
convert a list of attribute values to a DRSUAPI DsReplicaAttribute
def dsdb_normalise_attributes(self, ldb, ldap_display_name, ldif_elements):
normalise a list of attribute values
def get_attribute_from_attid(self, attid):
Get from an attid the associated attribute
ParametersattidThe attribute id for searched attribute
ReturnsThe name of the attribute associated with this id
def _populate_oid_attid(self):
Populate the hash hash_oid_name.

This hash contains the oid of the attribute as a key and its display name as a value

def get_attribute_replmetadata_version(self, dn, att):
Get the version field trom the replPropertyMetaData for the given field
ParametersdnThe on which we want to get the version
attThe name of the attribute
ReturnsThe value of the version field in the replPropertyMetaData for the given attribute. None if the attribute is not replicated
def set_attribute_replmetadata_version(self, dn, att, value, addifnotexist=False):
Undocumented
def write_prefixes_from_schema(self):
Undocumented
def get_partitions_dn(self):
Undocumented
def set_minPwdAge(self, value):
Undocumented
def get_minPwdAge(self):
Undocumented
def set_minPwdLength(self, value):
Undocumented
def get_minPwdLength(self):
Undocumented
def set_pwdProperties(self, value):
Undocumented
def get_pwdProperties(self):
Undocumented
def set_dsheuristics(self, dsheuristics):
Undocumented
def get_dsheuristics(self):
Undocumented
def create_ou(self, ou_dn, description=None, name=None, sd=None):
Creates an organizationalUnit object :param ou_dn: dn of the new object :param description: description attribute :param name: name atttribute :param sd: security descriptor of the object, can be an SDDL string or security.descriptor type
def sequence_number(self, seq_type):
Returns the value of the sequence number according to the requested type :param seq_type: type of sequence number
def get_dsServiceName(self):
get the NTDS DN from the rootDSE
def get_serverName(self):
get the server DN from the rootDSE
API Documentation for Samba, generated by pydoctor at 2011-12-08 20:23:28.