Home
%3CLINGO-SUB%20id%3D%22lingo-sub-385985%22%20slang%3D%22en-US%22%3ESQL%20Server%20on%20Linux%3A%20ADAuth%20issues%201%3A%20Issues%20with%20joining%20a%20VM%20to%20a%20domain%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-385985%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3EFirst%20published%20on%20MSDN%20on%20Sep%2004%2C%202018%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20AD%20authentication%20is%20a%20popular%20mechanism%20for%20login%20and%20user%20authentication.%20It%20works%20very%20well%20in%20many%20scenarios%2C%20especially%20for%20enterprise%20applications.%20AD%20authentication%20is%20a%20supported%20scenario%20on%20SQL%20Server%20on%20Linux.%20Configuring%20the%20Linux%20VM%20to%20join%20with%20Active%20Directory%20(AD)%20can%20be%20a%20little%20tricky%20at%20sometimes%20though%2C%20especially%20in%20a%20complex%20enterprise%20environment.%20%3CBR%20%2F%3E%3CUL%3E%3CBR%20%2F%3E%3CLI%3EOne%20error%20message%20you%20may%20see%20from%20%E2%80%9C%20%3CB%3E%20%3CI%3E%20realm%20join%20%3C%2FI%3E%20%3C%2FB%3E%20%E2%80%9D%20is%20%E2%80%9Crealm%3A%20Couldn%E2%80%99t%20join%20realm%3A%20This%20computer%E2%80%99s%20host%20name%20is%20not%20set%20correctly.%E2%80%9D%20This%20is%20due%20to%20a%20generic%20hostname%20(e.g.%20%E2%80%9Clocalhost%E2%80%9D)%2C%20an%20incorrect%20domain%20in%20your%20hostname%20(e.g.%20%E2%80%9Chost1.abcd.com%E2%80%9D%20instead%20of%20%E2%80%9Chost1.contoso.com%E2%80%9D)%2C%20or%20a%20duplicate%20hostname%20on%20the%20domain.%20To%20fix%20this%2C%20edit%20%3CB%3E%20%3CI%3E%20%2Fetc%2Fhostname%20%3C%2FI%3E%20%3C%2FB%3E%20to%20have%20a%20unique%20hostname%20and%20reboot%20the%20machine.%20On%20Ubuntu%2C%20it%20can%20also%20be%20helpful%20to%20put%20the%20fully%20qualified%20domain%20name%20in%20%3CB%3E%20%3CI%3E%20%2Fetc%2Fhostname%20%3C%2FI%3E%20%3C%2FB%3E%20(e.g.%20%E2%80%9Chost1.contoso.com%E2%80%9D%20instead%20of%20%E2%80%9Chost1%E2%80%9D).%3C%2FLI%3E%3CBR%20%2F%3E%3C%2FUL%3E%3CBR%20%2F%3E%20%3CBR%20%2F%3E%3CUL%3E%3CBR%20%2F%3E%3CLI%3EAnother%20possibility%20is%20that%20if%20the%20DNS%20is%20configured%20incorrectly%2C%20the%20host%20may%20be%20unable%20to%20resolve%20the%20domain.%20This%20will%20result%20in%20the%20message%20%E2%80%9C%20%3CB%3E%20%3CI%3E%20realm%3A%20No%20such%20realm%20found%20%3C%2FI%3E%20%3C%2FB%3E%20%E2%80%9D%20being%20returned%20from%20%E2%80%9C%20%3CB%3E%20%3CI%3E%20realm%20join%20%3C%2FI%3E%20%3C%2FB%3E%20%E2%80%9D%20command.%20To%20fix%20this%2C%20you%20need%20to%20use%20a%20DNS%20server%20on%20the%20realm%20you%20wish%20to%20join%20(can%20be%20on%20the%20same%20machine%20as%20the%20domain%20controller).%20The%20steps%20to%20fix%20this%20are%20described%20here%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Flinux%2Fsql-server-linux-active-directory-authentication%3Fview%3Dsql-server-2017%23join%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Flinux%2Fsql-server-linux-active-directory-authentication%3Fview%3Dsql-server-2017%23join%3C%2FA%3E%3C%2FLI%3E%3CBR%20%2F%3E%3C%2FUL%3E%3CBR%20%2F%3E%3CBLOCKQUOTE%3E%3CSTRONG%3EUbuntu%3A%20%3C%2FSTRONG%3E%20-%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Use%20nano%20editor%20(or%20your%20favorite%20editor)%20to%20edit%20the%20interfaces%20configuration.%20(You%20may%20need%20sudo%20privilege%20to%20edit%20the%20configuration.)%20%3CB%3E%20%3CI%3E%20%3CBR%20%2F%3E%20%24nano%20%2Fetc%2Fnetwork%2Finterfaces%20%3C%2FI%3E%20%3C%2FB%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20-%20Add%20the%20lines%20below%3A%20%3CBR%20%2F%3E%20%3CB%3E%20%3CI%3E%20auto%20eth0%20%3CBR%20%2F%3E%20iface%20eth0%20%3CBR%20%2F%3E%20dns-nameservers%20**%3CAD%20domain%3D%22%22%20controller%3D%22%22%20ip%3D%22%22%20address%3D%22%22%3E**%20%3CBR%20%2F%3E%20dns-search%20**%3CAD%20domain%3D%22%22%20name%3D%22%22%3E**%20%3C%2FAD%3E%3C%2FAD%3E%3C%2FI%3E%20%3C%2FB%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20-%20Save%20and%20close%20the%20interfaces%20configuration%20file.%20Then%20restart%20the%20network%20service%20by%20issuing%20following%20command.%20%3CBR%20%2F%3E%20%3CB%3E%3CI%3E%24sudo%20ifdown%20eth0%20%26amp%3B%26amp%3B%20ifup%20eth0%20%3C%2FI%3E%20%3C%2FB%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CB%3E%20Note%20%3C%2FB%3E%20%3A%20The%20network%20interface%20(eth0)%20might%20differ%20for%20different%20machines.%20To%20find%20out%20which%20one%20you%20are%20using%2C%20run%20ifconfig%20and%20copy%20the%20interface%20that%20has%20an%20IP%20address%20and%20transmitted%20and%20received%20bytes.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CSTRONG%3ERHEL%3A%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20-%20Use%20nano%20editor%20(or%20your%20favorite%20editor)%20to%20edit%20the%20eth0%20(or%20a%20more%20appropriate)%20interface%20configuration%20file.%20%3CBR%20%2F%3E%20%3CB%3E%3CI%3E%24nano%20%2Fetc%2Fsysconfig%2Fnetwork-scripts%2Fifcfg-eth0%20%3C%2FI%3E%20%3C%2FB%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20-%20Add%20the%20lines%20below%3A%20%3CBR%20%2F%3E%20%3CB%3E%20%3CI%3E%20peerDNS%3Dno%20%3CBR%20%2F%3E%20DNS1%3D**%3CAD%20domain%3D%22%22%20controller%3D%22%22%20ip%3D%22%22%20address%3D%22%22%3E**%20%3C%2FAD%3E%3C%2FI%3E%20%3C%2FB%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20-%20Save%20and%20exit%20the%20file.%20Restart%20the%20network%20service%20to%20apply%20the%20network%20configuration%20change.%20%3CBR%20%2F%3E%20%3CB%3E%20%3CI%3E%20%24systemctl%20restart%20network%20%3C%2FI%3E%20%3C%2FB%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%3C%2FBLOCKQUOTE%3E%3CBR%20%2F%3E%3CUL%3E%3CBR%20%2F%3E%3CLI%3EThe%20%3CB%3E%20%3CI%3E%20realm%20join%20%3C%2FI%3E%20%3C%2FB%3E%20may%20also%20fail%20saying%20there%20are%20required%20packages%20which%20are%20missing%20from%20your%20system.%20To%20fix%20this%20problem%2C%20simply%20install%20the%20packages%20and%20try%20to%20join%20again.%20%3CBR%20%2F%3E%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3EThe%20message%20%E2%80%9C%20%3CB%3E%20Insufficient%20permissions%20to%20join%20the%20domain%20%3C%2FB%3E%20%E2%80%9D%20means%20you%20need%20to%20use%20a%20different%20user%20when%20joining%20the%20domain.%20Not%20all%20users%20can%20add%20machines%20to%20a%20domain%2C%20so%20you%20must%20use%20a%20user%20with%20these%20permissions.%3C%2FLI%3E%3CBR%20%2F%3E%3C%2FUL%3E%3CBR%20%2F%3E%20General%20tips%3A%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20-%20use%20%E2%80%98-v%E2%80%99%20on%20realm%20commands%20to%20get%20more%20logging%20on%20what%20is%20failing%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20-%20You%20can%20test%20if%20your%20machine%20can%20contact%20the%20domain%20with%20command%20%E2%80%9C%20%3CB%3E%20%3CI%3E%20realm%20discover%20**contoso.com**%20%3C%2FI%3E%20%3C%2FB%3E%20%E2%80%9D%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Dylan%20Gray%20%7C%20Senior%20Software%20Engineer%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Tejas%20Shah%20%7C%20Senior%20Program%20Manager%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-385985%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20MSDN%20on%20Sep%2004%2C%202018%20AD%20authentication%20is%20a%20popular%20mechanism%20for%20login%20and%20user%20authentication.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-385985%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESQLServerTiger%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft
First published on MSDN on Sep 04, 2018
AD authentication is a popular mechanism for login and user authentication. It works very well in many scenarios, especially for enterprise applications. AD authentication is a supported scenario on SQL Server on Linux. Configuring the Linux VM to join with Active Directory (AD) can be a little tricky at sometimes though, especially in a complex enterprise environment.

  • One error message you may see from “ realm join ” is “realm: Couldn’t join realm: This computer’s host name is not set correctly.” This is due to a generic hostname (e.g. “localhost”), an incorrect domain in your hostname (e.g. “host1.abcd.com” instead of “host1.contoso.com”), or a duplicate hostname on the domain. To fix this, edit /etc/hostname to have a unique hostname and reboot the machine. On Ubuntu, it can also be helpful to put the fully qualified domain name in /etc/hostname (e.g. “host1.contoso.com” instead of “host1”).




  • Another possibility is that if the DNS is configured incorrectly, the host may be unable to resolve the domain. This will result in the message “ realm: No such realm found ” being returned from “ realm join ” command. To fix this, you need to use a DNS server on the realm you wish to join (can be on the same machine as the domain controller). The steps to fix this are described here: https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-active-directory-authentication?vi...


Ubuntu: -

Use nano editor (or your favorite editor) to edit the interfaces configuration. (You may need sudo privilege to edit the configuration.)
$nano /etc/network/interfaces


- Add the lines below:
auto eth0
iface eth0
dns-nameservers **<AD domain controller IP address>**
dns-search **<AD domain name>**


- Save and close the interfaces configuration file. Then restart the network service by issuing following command.
$sudo ifdown eth0 && ifup eth0


Note : The network interface (eth0) might differ for different machines. To find out which one you are using, run ifconfig and copy the interface that has an IP address and transmitted and received bytes.

RHEL:

- Use nano editor (or your favorite editor) to edit the eth0 (or a more appropriate) interface configuration file.
$nano /etc/sysconfig/network-scripts/ifcfg-eth0


- Add the lines below:
peerDNS=no
DNS1=**<AD domain controller IP address>**


- Save and exit the file. Restart the network service to apply the network configuration change.
$systemctl restart network



  • The realm join may also fail saying there are required packages which are missing from your system. To fix this problem, simply install the packages and try to join again.

  • The message “ Insufficient permissions to join the domain ” means you need to use a different user when joining the domain. Not all users can add machines to a domain, so you must use a user with these permissions.


General tips:

- use ‘-v’ on realm commands to get more logging on what is failing

- You can test if your machine can contact the domain with command “ realm discover **contoso.com**

Dylan Gray | Senior Software Engineer

Tejas Shah | Senior Program Manager