def bind_to_ad(loaner=False, hostname=None):
    def __bind():
        return shell_tools.run("""
      dsconfigad -f -a %s -u "%s" -p %s -domain %s -ou %s,%s
    """ % (bind_name[:13], config.LDAP_USER, config.LDAP_PASSWORD,
           config.BIND_DOMAIN, config.BIND_OU, config.BIND_DC))

    # If we're bound to AD...unbind from AD before rebinding
    shell_tools.run(
        "dsconfigad -f -r -force -u '%s' -p '%s'"
        % (config.LDAP_USER, config.LDAP_PASSWORD)
    )

    # Set the time before binding because process relies on synced time
    # between the client and the AD server
    sys_tools.configure_time()
    bind_name = sys_tools.get_computer_name()

    if hostname:
        bind_name = hostname

    bind = __bind()
    if bind['status'] == 70:
        sys_tools.log("account_tools-bind_to_ad", "Restarting opendirectoryd")
        shell_tools.run("killall opendirectoryd")
        sys_tools.sleep(secs=3)
        bind = __bind()

    if not bind['success']:
        sys_tools.log("account_tools-bind_to_ad", "Unable to bind to AD")
        raise Exception("Unable to bind to Active Directory")

    # Set additional AD settings
    bind_settings = [
        "dsconfigad -mobile enable",
        "dsconfigad -mobileconfirm disable",
    ]

    for setting in bind_settings:
        shell_tools.run("%s" % setting)
delete all files below a minimum size.
dataset/ETHPy150Open facebook/IT-CPE/code/lib/modules/account_tools.py/bind_to_ad--crossover with--dataset/ETHPy150Open CGATOxford/cgat/scripts/split_fasta.py/Files.DeleteFiles