Create Active Directory user procedure

# The following procedure creates an Active Directory user if an
# account with the same distinguished name does not already exist.
proc my_create_aduser {dn upn sam pw} {
            if { [catch {select_object $dn}] } {
        # If we fail to select the object, the account
        # does not exist. So we create it here.
        puts "Creating $dn"
        create_aduser $dn $upn $sam $pwd
    } else {
        puts "$dn exists. Do not create."
    }
}