#NEWLINE# def __init__( self , domain_sid , invocationid = None , schemadn = None , files = None , override_prefixmap = None , additional_prefixmap = None ) : #NEWLINE# #INDENT# from samba.provision import setup_path #NEWLINE# 'Load schema for the SamDB from the AD schema files and\n        samba4_schema.ldif\n\n        :param samdb: Load a schema into a SamDB.\n        :param schemadn: DN of the schema\n\n        Returns the schema data loaded, to avoid double-parsing when then\n        needing to add it to the db\n        ' #NEWLINE# self . schemadn = schemadn #NEWLINE# self . ldb = SamDB ( global_schema = False , am_rodc = False ) #NEWLINE# if ( invocationid is not None ) : #NEWLINE# #INDENT# self . ldb . set_invocation_id ( invocationid ) #NEWLINE# #UNINDENT# self . schema_data = read_ms_schema ( setup_path ( 'ad-schema/MS-AD_Schema_2K8_R2_Attributes.txt' ) , setup_path ( 'ad-schema/MS-AD_Schema_2K8_R2_Classes.txt' ) ) #NEWLINE# if ( files is not None ) : #NEWLINE# #INDENT# for file in files : #NEWLINE# #INDENT# self . schema_data += open ( file , 'r' ) . read ( ) #NEWLINE# #UNINDENT# #UNINDENT# self . schema_data = substitute_var ( self . schema_data , { #NEWLINE# #INDENT# 'SCHEMADN' : schemadn , #NEWLINE# #UNINDENT# } ) #NEWLINE# check_all_substituted ( self . schema_data ) #NEWLINE# self . schema_dn_modify = read_and_sub_file ( setup_path ( 'provision_schema_basedn_modify.ldif' ) , { #NEWLINE# #INDENT# 'SCHEMADN' : schemadn , #NEWLINE# #UNINDENT# } ) #NEWLINE# descr = b64encode ( get_schema_descriptor ( domain_sid ) ) #NEWLINE# self . schema_dn_add = read_and_sub_file ( setup_path ( 'provision_schema_basedn.ldif' ) , { #NEWLINE# #INDENT# 'SCHEMADN' : schemadn , #NEWLINE# 'DESCRIPTOR' : descr , #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( override_prefixmap is not None ) : #NEWLINE# #INDENT# self . prefixmap_data = override_prefixmap #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . prefixmap_data = open ( setup_path ( 'prefixMap.txt' ) , 'r' ) . read ( ) #NEWLINE# #UNINDENT# if ( additional_prefixmap is not None ) : #NEWLINE# #INDENT# for map in additional_prefixmap : #NEWLINE# #INDENT# self . prefixmap_data += ( '%s\n' % map ) #NEWLINE# #UNINDENT# #UNINDENT# self . prefixmap_data = b64encode ( self . prefixmap_data ) #NEWLINE# prefixmap_ldif = ( 'dn: %s\nprefixMap:: %s\n\n' % ( self . schemadn , self . prefixmap_data ) ) #NEWLINE# self . set_from_ldif ( prefixmap_ldif , self . schema_data , self . schemadn )