Index: 96univention-samba4.inst =================================================================== --- 96univention-samba4.inst (Revision 69856) +++ 96univention-samba4.inst (Arbeitskopie) @@ -317,35 +317,19 @@ exit 1 fi else - if samba-tool domain info "$domainname"; then - samba-tool domain join "$domainname" "$samba4_role" "${samba_join_options[@]}" + s4connector_dc=$(get_available_s4connector_dc) || return $? + s4connector_dc_fqdn="$s4connector_dc.$domainname" + if samba-tool domain info "$s4connector_dc_fqdn"; then + samba-tool domain join "$domainname" "$samba4_role" --server "$s4connector_dc_fqdn" "${samba_join_options[@]}" if [ $? -eq 0 ]; then success=true + univention-config-registry set windows/wins-server?"$s4connector_dc_fqdn" + break else - echo "Failed to join the domain $domainname." + echo "Failed to join the server $s4connector_dc_fqdn" exit 1 fi fi - - if [ -z "$success" ]; then - # try again with --server - cn=($(ldapsearch -x -ZZ -LLL -D "$ldap_hostdn" -y /etc/machine.secret \ - "(&(univentionService=Samba 4)(objectClass=univentionDomainController))" cn \ - | ldapsearch-wrapper | sed -n 's/^cn: \(.*\)/\1/p' )) - for name in "${cn[@]}"; do - if samba-tool domain info "$name.$domainname"; then - samba-tool domain join "$domainname" "$samba4_role" --server "$name.$domainname" "${samba_join_options[@]}" - if [ $? -eq 0 ]; then - success=true - univention-config-registry set windows/wins-server?"$name.$domainname" - break - else - echo "Failed to join the server $name.$domainname." - exit 1 - fi - fi - done - fi fi