How to use command-line commands to log in a domain?

Posted on 2009-06-30
Last Modified: 2012-06-27
I have some users in Sales department visiting several different sister companies in our group. Each sister company has their own domain. When they visit, they want to use the local resources such as printers, scanners, network drivers, etc. I want to know if there is a way of loging to a domain by using command-line commands so I can plug them in the login script. With this, they will be able to login to the local domain whichever company they visit.
Question by:Castlewood
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2

Expert Comment

ID: 24747918
net use t: \\server\common /user:chris 12345

That will map the local T: drive to the common share on the server using the username chris and password 12345

You can also change the username to the format "domain\user"  eg microsoft\bill will use the username bill on the Windows domain microsoft.

If you just simply want to login to a server, but not map a drive, then just leave out the drive letter and that will process the initial login.
LVL 70

Expert Comment

ID: 24748105
I don't think the above mentioned approach will suffice, as you need to use the same server name and at least one common share in all domains, and it does not allow for usage of domain resources, only for that single server.

If you make sure the local account is replicated into all domains (including the same password), you shouldn't have any problems browsing the local domain and using its resources. The laptop users will stay local, but whenever they access the domain, they will do with the domain account with same name.

It could be necessary to have the laptop be part of the local domain - that would be difficult, as you can only have ONE domain membership.

(I assumed those users are accessing domain resources with their own laptop on travelling.)

Author Comment

ID: 24749597
Qlemo, the domains are not under the same tree so there is no replication between. You are correct that those users are accessing domain resources with their own laptop on travelling. When they turn power on and login to their own laptops it is their "home" domain they log into using the user's profile. I think the question is more like: can they log in to multiple domains? If yes, how and what commands to use in user's login script?  

We currently use "net use". It seems cumbersome since there are so many resources to share. If they can log into the local domain by a command, it will be really awesome.

Can Net Use be used to share for an entire domain's resources, instead of just per server? If not, Net Use is not sufficient, since it is the command we currently use.
Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

LVL 70

Expert Comment

ID: 24749694
Net use can't do that. It authorizes against a single server only, not the domain.

With "replication" I ment a manual way of duplicating related accounts to all domains. Which makes only sense if you have no account changes (including passwords), or a connection between all domains (at least at a single point of access).

You cannot be member of more than one domain at any time. You can change the logon domain, but I do not know (as I never tried) if that is really feasible with changing domains. The reg key for login domain is
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ WindowsNT\CurrentVersion\Winlogon\DefaultDomain
You can try to change that and if it would work. The laptop will have to be member of the domain, I reckon. This is something you have to do once for each laptop in each domain.


Expert Comment

ID: 24749841
I agree with Qlemo that you can only join one domain.  And since these domains are separate and not under the same tree, there is no way to log in to multiple domains.

If I had this problem, I would have setup a more complicated login script that would detect which network I'm on, then run the appropriate login commands to login to the individual servers that had the needed network resources.

But I didn't know that you could replicate local user accounts across a domain like Qlemo suggested.  If that isn't too hard, then it might prove to be a better solution.

Accepted Solution

brasslan earned 250 total points
ID: 24749883
Oops, I was really slow in posting my last post and didn't see Qlemo's last note...

You can't change your registry to login to another domain.  You need more than a user account to login from a windows computer, you also need a computer account listed in the active directory on the domain as well.  As you know, after deleting a computer from Active Directory Users and Computers, no one can login to the domain from that PC anymore.

Author Comment

ID: 24750358
Wait, does a computer need to join the domain before the user using this computer can login to this domain ??
LVL 70

Assisted Solution

Qlemo earned 250 total points
ID: 24752814
Only on a member computer you can login in using the domain account. However, if the domain account and the local account are the same (and using the same password), it should work, but it could also be necessary to login on each server providing the domain user.

We use that kind of login on most workstations (local login, domain login data = local login data), and for access between the workstations you have to give explicit domain login (sometimes).

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  ( Here (http…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor ( Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question