How to detect the user has logged in a domain or local host in the linux shell script? The Next CEO of Stack OverflowGetting Linux computer integrated with Windows domainUnable to log in to Ubuntu server 10.04 after trying to join Windows domainAllow AD Groups to SUDOHow to remove unwanted Windows domain accounts and local account from Linux Mint 17 login screen?pssh (Parallel-ssh) passing different parameter for every hostHow to correctly set hostname and domain name?Can't create samba 4 share which accepts domain credentialsAfter joining with AD user, changing [User@domain@host] to [user@host]How to set sftp-server permissions and ownership in a shared sftp-folder? (ACL's ?)Debian Stretch: Samba Winbind Offline Logon Not working - kerberos keytab not persistent after reboot?
How to avoid supervisors with prejudiced views?
Make solar eclipses exceedingly rare, but still have new moons
Recycling old answers
Help understanding this unsettling image of Titan, Epimetheus, and Saturn's rings?
What connection does MS Office have to Netscape Navigator?
Solving system of ODEs with extra parameter
What flight has the highest ratio of time difference to flight time?
Would a grinding machine be a simple and workable propulsion system for an interplanetary spacecraft?
Prepend last line of stdin to entire stdin
Newlines in BSD sed vs gsed
Is there always a complete, orthogonal set of unitary matrices?
Why is quantifier elimination desirable for a given theory?
Is it ever safe to open a suspicious HTML file (e.g. email attachment)?
Why does the flight controls check come before arming the autobrake on the A320?
Why do remote US companies require working in the US?
Is it professional to write unrelated content in an almost-empty email?
How to install OpenCV on Raspbian Stretch?
Is micro rebar a better way to reinforce concrete than rebar?
Does soap repel water?
What steps are necessary to read a Modern SSD in Medieval Europe?
Why don't programming languages automatically manage the synchronous/asynchronous problem?
Why does standard notation not preserve intervals (visually)
How did people program for Consoles with multiple CPUs?
Method for adding error messages to a dictionary given a key
How to detect the user has logged in a domain or local host in the linux shell script?
The Next CEO of Stack OverflowGetting Linux computer integrated with Windows domainUnable to log in to Ubuntu server 10.04 after trying to join Windows domainAllow AD Groups to SUDOHow to remove unwanted Windows domain accounts and local account from Linux Mint 17 login screen?pssh (Parallel-ssh) passing different parameter for every hostHow to correctly set hostname and domain name?Can't create samba 4 share which accepts domain credentialsAfter joining with AD user, changing [User@domain@host] to [user@host]How to set sftp-server permissions and ownership in a shared sftp-folder? (ACL's ?)Debian Stretch: Samba Winbind Offline Logon Not working - kerberos keytab not persistent after reboot?
In the default, the linux doesn't support the domain. But the user can join a domain by applictions, such as: Likewise, Winbind, and so on.
For my project, my customers are all enterprise members. For the security problem, most customers' linux host will be joined a domain.
Unfortunately, the customer can log in the local host even the linux host has been joined a domain. Such as:
(1) The are two accounts in a linux host:
a domain account: dev.comjohn(the domain is developer.com)
a local account: tom
(2) The customer can log in with the domain account(dev.comjohn) or local account(tom) freely.
My task is that write a shell script that will be executed when the user log in. In the shell script, I need to check the user log in with a domain account or a local account.
If the user log in with the domain name, I need to get the domain name ; otherwise, I need to get the host name. Then report the domain(or host) name and user name to the remote monitor server.
I have tried the following code:
hostName=$(hostname)
hostFQDN=$(hostname -f)
if [ "$hostName" = "$hostFQDN" ]; then
# The user didn't log in a domain.
hostInfo="$hostName"
else
# The user logged in a domain.
hostInfo=$(hostname -d)
fi
In the above, I check the host FQDN is equal with the host name or not. If yes, I will believe the customer log in with the domain account; else, local account.
Unfortunately, it doesn't work always. The reason is that the host FQDN will not equal with host name always if the linux host is joined a domain, even the customer log in with a local account. Such as:
(1) The linux host is joined the domain "dev.com";
(2) The host fqdn will be "yw-host.dev.com" always("yw-host" is the host name), whether the customer log in with domain account or not.
Anybody can give a solution please? As my customer can join the domain with multiple domain applications(such as: likewise, winbin, and so on), it is better the solution will not depend on a special domain application.
Thanks a lot.
linux shell-script domain
add a comment |
In the default, the linux doesn't support the domain. But the user can join a domain by applictions, such as: Likewise, Winbind, and so on.
For my project, my customers are all enterprise members. For the security problem, most customers' linux host will be joined a domain.
Unfortunately, the customer can log in the local host even the linux host has been joined a domain. Such as:
(1) The are two accounts in a linux host:
a domain account: dev.comjohn(the domain is developer.com)
a local account: tom
(2) The customer can log in with the domain account(dev.comjohn) or local account(tom) freely.
My task is that write a shell script that will be executed when the user log in. In the shell script, I need to check the user log in with a domain account or a local account.
If the user log in with the domain name, I need to get the domain name ; otherwise, I need to get the host name. Then report the domain(or host) name and user name to the remote monitor server.
I have tried the following code:
hostName=$(hostname)
hostFQDN=$(hostname -f)
if [ "$hostName" = "$hostFQDN" ]; then
# The user didn't log in a domain.
hostInfo="$hostName"
else
# The user logged in a domain.
hostInfo=$(hostname -d)
fi
In the above, I check the host FQDN is equal with the host name or not. If yes, I will believe the customer log in with the domain account; else, local account.
Unfortunately, it doesn't work always. The reason is that the host FQDN will not equal with host name always if the linux host is joined a domain, even the customer log in with a local account. Such as:
(1) The linux host is joined the domain "dev.com";
(2) The host fqdn will be "yw-host.dev.com" always("yw-host" is the host name), whether the customer log in with domain account or not.
Anybody can give a solution please? As my customer can join the domain with multiple domain applications(such as: likewise, winbin, and so on), it is better the solution will not depend on a special domain application.
Thanks a lot.
linux shell-script domain
I have an idea that check the user id is in the file etc/passwd or not. If yes, it should be a local account; else, a domain account. I am not sure this solution is correct or not.
– yw5643
May 13 '15 at 7:21
Anybody can give some comments? Thanks.
– yw5643
May 18 '15 at 2:50
add a comment |
In the default, the linux doesn't support the domain. But the user can join a domain by applictions, such as: Likewise, Winbind, and so on.
For my project, my customers are all enterprise members. For the security problem, most customers' linux host will be joined a domain.
Unfortunately, the customer can log in the local host even the linux host has been joined a domain. Such as:
(1) The are two accounts in a linux host:
a domain account: dev.comjohn(the domain is developer.com)
a local account: tom
(2) The customer can log in with the domain account(dev.comjohn) or local account(tom) freely.
My task is that write a shell script that will be executed when the user log in. In the shell script, I need to check the user log in with a domain account or a local account.
If the user log in with the domain name, I need to get the domain name ; otherwise, I need to get the host name. Then report the domain(or host) name and user name to the remote monitor server.
I have tried the following code:
hostName=$(hostname)
hostFQDN=$(hostname -f)
if [ "$hostName" = "$hostFQDN" ]; then
# The user didn't log in a domain.
hostInfo="$hostName"
else
# The user logged in a domain.
hostInfo=$(hostname -d)
fi
In the above, I check the host FQDN is equal with the host name or not. If yes, I will believe the customer log in with the domain account; else, local account.
Unfortunately, it doesn't work always. The reason is that the host FQDN will not equal with host name always if the linux host is joined a domain, even the customer log in with a local account. Such as:
(1) The linux host is joined the domain "dev.com";
(2) The host fqdn will be "yw-host.dev.com" always("yw-host" is the host name), whether the customer log in with domain account or not.
Anybody can give a solution please? As my customer can join the domain with multiple domain applications(such as: likewise, winbin, and so on), it is better the solution will not depend on a special domain application.
Thanks a lot.
linux shell-script domain
In the default, the linux doesn't support the domain. But the user can join a domain by applictions, such as: Likewise, Winbind, and so on.
For my project, my customers are all enterprise members. For the security problem, most customers' linux host will be joined a domain.
Unfortunately, the customer can log in the local host even the linux host has been joined a domain. Such as:
(1) The are two accounts in a linux host:
a domain account: dev.comjohn(the domain is developer.com)
a local account: tom
(2) The customer can log in with the domain account(dev.comjohn) or local account(tom) freely.
My task is that write a shell script that will be executed when the user log in. In the shell script, I need to check the user log in with a domain account or a local account.
If the user log in with the domain name, I need to get the domain name ; otherwise, I need to get the host name. Then report the domain(or host) name and user name to the remote monitor server.
I have tried the following code:
hostName=$(hostname)
hostFQDN=$(hostname -f)
if [ "$hostName" = "$hostFQDN" ]; then
# The user didn't log in a domain.
hostInfo="$hostName"
else
# The user logged in a domain.
hostInfo=$(hostname -d)
fi
In the above, I check the host FQDN is equal with the host name or not. If yes, I will believe the customer log in with the domain account; else, local account.
Unfortunately, it doesn't work always. The reason is that the host FQDN will not equal with host name always if the linux host is joined a domain, even the customer log in with a local account. Such as:
(1) The linux host is joined the domain "dev.com";
(2) The host fqdn will be "yw-host.dev.com" always("yw-host" is the host name), whether the customer log in with domain account or not.
Anybody can give a solution please? As my customer can join the domain with multiple domain applications(such as: likewise, winbin, and so on), it is better the solution will not depend on a special domain application.
Thanks a lot.
linux shell-script domain
linux shell-script domain
asked May 13 '15 at 7:20
yw5643yw5643
58211
58211
I have an idea that check the user id is in the file etc/passwd or not. If yes, it should be a local account; else, a domain account. I am not sure this solution is correct or not.
– yw5643
May 13 '15 at 7:21
Anybody can give some comments? Thanks.
– yw5643
May 18 '15 at 2:50
add a comment |
I have an idea that check the user id is in the file etc/passwd or not. If yes, it should be a local account; else, a domain account. I am not sure this solution is correct or not.
– yw5643
May 13 '15 at 7:21
Anybody can give some comments? Thanks.
– yw5643
May 18 '15 at 2:50
I have an idea that check the user id is in the file etc/passwd or not. If yes, it should be a local account; else, a domain account. I am not sure this solution is correct or not.
– yw5643
May 13 '15 at 7:21
I have an idea that check the user id is in the file etc/passwd or not. If yes, it should be a local account; else, a domain account. I am not sure this solution is correct or not.
– yw5643
May 13 '15 at 7:21
Anybody can give some comments? Thanks.
– yw5643
May 18 '15 at 2:50
Anybody can give some comments? Thanks.
– yw5643
May 18 '15 at 2:50
add a comment |
1 Answer
1
active
oldest
votes
The full user login detail should be in your secure or audit log depending on which distro you are using.
It is a simple quick fix to check if they exist in /etc/passwd but you could have issues with duplicate usernames.
New contributor
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f203107%2fhow-to-detect-the-user-has-logged-in-a-domain-or-local-host-in-the-linux-shell-s%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The full user login detail should be in your secure or audit log depending on which distro you are using.
It is a simple quick fix to check if they exist in /etc/passwd but you could have issues with duplicate usernames.
New contributor
add a comment |
The full user login detail should be in your secure or audit log depending on which distro you are using.
It is a simple quick fix to check if they exist in /etc/passwd but you could have issues with duplicate usernames.
New contributor
add a comment |
The full user login detail should be in your secure or audit log depending on which distro you are using.
It is a simple quick fix to check if they exist in /etc/passwd but you could have issues with duplicate usernames.
New contributor
The full user login detail should be in your secure or audit log depending on which distro you are using.
It is a simple quick fix to check if they exist in /etc/passwd but you could have issues with duplicate usernames.
New contributor
New contributor
answered 2 days ago
KoffeeKoffee
13
13
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f203107%2fhow-to-detect-the-user-has-logged-in-a-domain-or-local-host-in-the-linux-shell-s%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I have an idea that check the user id is in the file etc/passwd or not. If yes, it should be a local account; else, a domain account. I am not sure this solution is correct or not.
– yw5643
May 13 '15 at 7:21
Anybody can give some comments? Thanks.
– yw5643
May 18 '15 at 2:50