Create Active Directory group procedure

# The following procedure creates an Active Directory group if a
# group with the same distinguished name does not already exist.
proc my_create_adgroup {dn sam gtype} {
            if { [catch {select_object $dn}] } {
        # If we fail to select the object, the group
        # does not exist. So we create it here.
        puts "Creating $dn"
        create_adgroup $dn $sam $gtype
    } else {
        puts "$dn exists. Do not create."