In this guide, you will learn how to join a Windows computer to an Active Directory domain over a VPN connection. This scenario is common when working remotely without direct access to the corporate network.
After joining a domain, Windows requires a reboot. However, without an active VPN connection, the computer cannot contact a domain controller, which prevents domain logon.
Connect to VPN Before Sign-in Windows (Recommended Method)
You can use a more elegant solution that allows you to establish a VPN connection before the user logs in to Windows, without having to switch between local and domain accounts.
Suppose you’ve configured a VPN connection under the local user. These VPN connection settings are stored in the rasphone.pbk file in the user profile folder (%userprofile%\ AppData\ Roaming\ Microsoft\ Network\ Connections\ PBK). In order to make this VPN profile available to all users of the computer, you need to copy the file containing the settings for the VPN connection to the public profile C:\ ProgramData\ Microsoft\ Network\ Connections\ PBK. This makes the VPN connection available on the Windows login screen for all users.
Copy the rasphone.pbk file manually by using File Explorer or with the PowerShell command:
# Copy VPN profile to All Users (Common) profile $Source = "$Env:USERPROFILE\AppData\Roaming\Microsoft\Network\Connections\PBK\rasphone.pbk" $Destination = "$Env:ALLUSERSPROFILE\Microsoft\Network\Connections\PBK\rasphone.pbk"
On the Windows logon screen, click the Network Connections icon in the bottom right-hand corner of the screen;
Specify the user credentials to connect to the VPN server;
Your computer should establish a VPN tunnel and you should be able to log in to Windows using your domain account.
To create a public VPN connection profile that is available on the Windows logon screen, you can also use the Add-VpnConnection PowerShell cmdlet with the AllUserConnection parameter enabled.
Create a new Virtual Private Network connection to your corporate VPN gateway.
Open the โWindows Settingsโ โ โNetwork & Internetโ;
Choose the โVPNโ tab and click on โAdd a VPN connectionโ;
Fill in the fields as follows: VPN Provider: Windows (built-in) Connection name: any name Server name or address: VPN server FQDN or IP VPN type: Automatic Sign-in info: Username and password
Click on โSaveโ button.
Connect to your VPN gateway.
Join your computer to the AD domain
Important. Before you will try to join the domain, you must ensure that your machine can resolve the domain name through the VPN tunnel. In case your machine uses your home router’s DNS instead of the corporate one, the join process will fail.
Run Command Prompt.
Type the command and press Enter:
nslookup yourdomain.com
(Replace “yourdomain” with your actual AD domain name).
Now you need to check the result:
If you see the IP address of your Domain Controller, proceed to the next step.
If you get a “Non-existent domain” error, you need to manually go to your VPN adapter settings and set the corporate DNS server IP address in the IPv4 properties.
Open the System Properties dialog by running the sysdm.cpl command;
Click on the โChangeโ button on the โComputer Nameโ tab;
Select the option โDomainโ, type your AD domain name, and press OK;
Enter the credentials of the user who is allowed to join the computer to the domain;
Restart the computer.
Join Domain Using PowerShell (optional)
Also, you can join your Windows device to Active Directory domain using PowerShell. You can use PowerShell console when automating domain join or deploying multiple machines:
Now add the domain user you will be using to the local administratorโs group on the computer. You can add a domain user account to the local group by its SID.
Note. We recommend you to use the SID method only if the domain name cannot be resolved at this point.
Ask your colleagues to find your domain account SID by using the following PowerShell command:
Get-Aduser M.Becker|select sid
You can now use PowerShell to add this account by its SID to the local Administrators group:
Then press CTRL+ALT+DEL and select the “Switch user” option. This allows you to log in with your domain account while keeping the VPN session active.
Enter your domain user credentials (use the following format of the username: domain\username) and login to a computer.
You are now logged in with your domain account on a domain-joined machine.
After you sign in for the first time, your domain user credentials are cached locally and you can sign in with your domain account even if the VPN is not connected.
Hint. If the Switch User option is missing, check the local GPO option Hide Entry Points for Fast User Switching under the following section: Computer configuration > Administrative Templates > System > Logon.
Summary
The most reliable method is to configure VPN before Windows logon. Other methods depend on your environment and access level.
The recommended method is VPN before Windows logon, as it allows you to authenticate to the domain immediately after reboot without switching between local and domain accounts.
After joining a domain, Windows requires a reboot. If the VPN is not active, the computer cannot reach a domain controller, which prevents domain logon.
I enjoy technology and developing websites. Since 2012 I'm running a few of my own websites, and share useful content on gadgets, PC administration and website promotion.
I’m experiencing an issue where I have joined the remote pc to the remote server’s domain controller. When I log back into the domain joined account, I can no longer establish an OpenVPN connection. If I log out, I can easily establish an OenVPN connection on the local admin account. What’s going on here?
I guess he means add your domain\user1 to Administrators group
I’m experiencing an issue where I have joined the remote pc to the remote server’s domain controller. When I log back into the domain joined account, I can no longer establish an OpenVPN connection. If I log out, I can easily establish an OenVPN connection on the local admin account. What’s going on here?