LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 09-21-2007, 05:46 AM   #1
kool_kid
Member
 
Registered: Sep 2004
Location: Dubai, UAE
Distribution: RHL
Posts: 350

Rep: Reputation: 30
copying windows users to samba


hiya

is it possible to copy the windows 2k3 Active Directory users id n pass to samba PDC? if yes how? Thanks
 
Old 09-21-2007, 07:36 AM   #2
jviola
Member
 
Registered: May 2004
Posts: 47

Rep: Reputation: 15
Importing users from Windows AD

I hope I understand your question. This might get you going in the right direction.

#!/bin/ksh -x
# This script will login to the Windows Active Directory and grab a list of
# all the windows users and filter out the users that you don't want to
# create a linux account for. Then it will create a linux account and
# home directory.
# SMBUSER must be a name in the Domain Admin group. SMBPASS is the Domain Admin user's password.
# WORKGROUP is the NETBIOS DOMAIN name.
# SMBSERVER is one of the Domain Controller that has AD names.
# TMP_LIST is the list of all Windows users.
# TMP_USERS is the list of Windows users that you want to create Linux accounts for.
#EXCLUDE is a list of users that are in TMP_LIST that you don't want to create a linux account for.

SMBUSER=administrator
SMBPASS=password
WORKGROUP=DOMAINNAME
SMBSERVER=IPADDRESS
TMP_LIST="/tmp/list.tmp"
TMP_USERS="/tmp/users.tmp"
EXCLUDE="/tmp/non_user_list.txt"

# This command is used to get all the users in Windows Active Directory
net rpc user -l -U ${SMBUSER}%${SMBPASS} -W $WORKGROUP -S $SMBSERVER > $TMP_LIST


# This line is used to eliminate unwanted accounts from windows.
cat $TMP_LIST | awk '{print $1}' | grep -v -f $EXCLUDE | grep -v '^$' > $TMP_USERS

# make a backup of the password and shadow file.
cp -p /etc/passwd /etc/passwd.bak
cp -p /etc/shadow /etc/shadow.bak



# foreach user in MSWindows lookup it in the Unix database.
for user in `cat $TMP_USERS`; do

# Check if the user already exists in unix database
grep -q ^${user}: /etc/passwd
if [ "$?" != "0" ]; then

# If the users don't exist then this line will create an account
# and home directory for them.

/usr/sbin/useradd -c "$user" -d /home/$user -m -g 100 -s /bin/ksh $user
 
Old 09-25-2007, 01:58 PM   #3
kool_kid
Member
 
Registered: Sep 2004
Location: Dubai, UAE
Distribution: RHL
Posts: 350

Original Poster
Rep: Reputation: 30
Thanks alot i will try it out
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems accessing Windows with SAMBA (group users) Micro420 Linux - Networking 3 06-15-2006 10:37 PM
how to open port for Linux Samba for windows users 12345671 Linux - Security 6 03-08-2004 02:42 AM
copying kde configuration for 2 users OR 2 users on 1 x session for vnc blackphiber Linux - General 0 02-26-2004 08:57 PM
samba file share with windows users Peds222 Linux - Software 6 08-22-2003 12:07 PM
samba, and users, and windows, OHH MY! tengofamilia Linux - Networking 1 01-27-2003 12:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 03:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration