Samba Ad
Samba Ad
php/3487081
Back to Article
Presumably you already have a functioning Active Directory domain, and know how
to run it. AD is very dependent on DNS (domain name system) so I'll assume your
DNS house is also in order. On your Linux box you'll need Samba 3, version 3.0.8
or newer. Plus MIT Kerberos 5, version 1.3.1 or newer, and OpenLDAP. (The Samba
documentation states that Heimdal Kerberos, version 0.6.3 or newer, also works.
The examples in this article use MIT Kerberos.) Debian users need the krb5-user,
krb5-config, krb5-doc, and libkrb53 packages. Red Hat and Fedora users need the
krb5 and krb5-client RPMs.
First you should verify that your Samba installation has been compiled to support
Kerberos, LDAP, Active Directory, and Winbind. Most likely it has, but you need to
make sure. The smbd command has a switch for printing build information. You
will see a lot more lines of output than are shown here:
root@windbag:/usr/sbin# cd /usr/sbin
root@windbag:/usr/sbin# smbd -b | grep LDAP
HAVE_LDAP_H
HAVE_LDAP
HAVE_LDAP_DOMAIN2HOSTLIST
...
root@windbag:/usr/sbin# smbd -b | grep KRB
HAVE_KRB5_H
HAVE_ADDRTYPE_IN_KRB5_ADDRESS
HAVE_KRB5
...
root@windbag:/usr/sbin# smbd -b | grep ADS
WITH_ADS
WITH_ADS
root@windbag:/usr/sbin# smbd -b | grep WINBIND
WITH_WINBIND
WITH_WINBIND
If you are in the unfortunate position of missing any of these, which will be
indicated by a blank line, you need to recompile Samba. See Chapter 37 of the The
Official Samba-3 HOWTO and Reference Guide.
Let's say our Active Directory domain server is bigserver.domain.net, and the
Samba server is named samba1. This is the absolute minimum Kerberos
configuration file, /etc/krb5.conf, for connecting to this domain:
'libdefaults'
default_realm = DOMAIN.NET
'realms' DOMAIN.NET = {
kdc = bigserver.domain.net
}
'domain_realms'
.kerberos.server = DOMAIN.NET
Use uppercase where it shows. Now try to connect, and mind your cases:
# kinit Administrator@DOMAIN.NET
Password for Administrator@DOMAIN.NET
Configure /etc/hosts
Even if your DNS servers are perfect in every way, it is a good idea to add
important servers to your local /etc/hosts file. It speeds up lookups and provides a
fallback in case the DNS servers go down:
www.enterprisenetworkingplanet.com/netos/article.php/3487081
Back to Article
Join Samba 3 to Your Active Directory Domain
By Carla Schroder
March 2, 2005
Configure Samba
This example smb.conf shows a basic setup for a printer server and home shares.
Shares are configured in the usual manner, only the global section changes when
you join to an AD domain.
# Global parameters
'global'
workgroup = BIGSERVER
realm = DOMAIN.NET
preferred master = no
server string = Samba file and print server
security = ADS
encrypt passwords = yes
log level = 3
log file = /var/log/samba/%m
max log size = 50
winbind separator = +
printcap name = cups
printing = cups
idmap uid = 10000-20000
idmap gid = 10000-20000
'homes'
comment = Home Directories
valid users = %S
read only = No
browseable = No
'printers'
comment = All Printers
browseable = no
printable = yes
guest ok = yes
$ testparm
This checks smb.conf for syntax errors. Any errors must be corrected before going
ahead. Then start up Samba:
# /etc/init.d/samba start
Hurrah! Success. The Samba box will now appear as a machine account under
"Computers" in your AD console. Now stop Samba until the final steps are
completed.
www.enterprisenetworkingplanet.com/netos/article.php/3487081
Back to Article
Enabling Windbind
Debian users may need to install the winbind package separately. RPM users will
find it in the samba-common RPM. First, edit /etc/nsswitch.conf. The first three
lines are the most important; the others vary according to your system:
# winbind
# /etc/init.d/samba start
Now verify that windbind is working. These commands pull lists of users and groups
from the AD domain controller:
# wbinfo -u
BIGSERVER+Administrator
BIGSERVER+Guest
BIGSERVER+cschroder
BIGSERVER+mhall
# wbinfo -g
BIGSERVER+Domain Computers
BIGSERVER+Domain Admins
BIGSERVER+Domain Guests
BIGSERVER+Domain Users
This command verifies that logins and passwords are coming from the AD server,
and not the local machine:
# getent passwd
BIGSERVER+cschroder:x:1000:1000:,,,:/home/BIGSERVER/cschroder:/bin/
bash
If winbind is not working and local authentication is still active, they will not have
the BIGSERVER+ prefix. Finally, as root run net ads info to display the AD server
information.
Troubleshooting
If you've gotten this far and everything works, your Samba server is now a fully-
fledged member of your Active Directory domain, and can be managed like any
other AD object. A nice bonus is you may have local Linux accounts on the Samba
box that are not visible in Active Directory; which means your Samba admins can
SSH directly into the Samba server for admin chores, and not have to fuss with AD
roadblocks.
Resources
Name
net — Tool for administration of Samba and remote CIFS servers.
Synopsis
net {<ads|rap|rpc>} [-h] [-w workgroup] [-W myworkgroup] [-U user] [-I ip-address] [-
p port] [-n myname] [-s conffile] [-S server] [-l] [-P] [-d debuglevel] [-V] [--request-
timeout seconds]
DESCRIPTION
This tool is part of the samba(7) suite.
The Samba net utility is meant to work just like the net utility available for windows
and DOS. The first argument should be used to specify the protocol to use when
executing a certain command. ADS is used for ActiveDirectory, RAP is using for old
(Win9x/NT3) clients and RPC can be used for NT4 and Windows 2000. If this
argument is omitted, net will try to determine it automatically. Not all commands are
available on all protocols.
OPTIONS
-h|--help
-w target-workgroup
Sets target workgroup or domain. You have to specify either this option or the IP
address or the name of a server.
-W workgroup
-U user
-I ip-address
IP address of target server to use. You have to specify either this option or a
target workgroup or a target server.
-p port
Port on the target server to connect to (usually 139 or 445). Defaults to trying
445 first, then 139.
This option allows you to override the NetBIOS name that Samba uses for itself.
This is identical to setting the parameter in the smb.conf file. However, a
command line setting will take precedence over settings in smb.conf.
The file specified contains the configuration details required by the server. The
information in this file includes server-specific information such as what
printcap file to use, as well as descriptions of all the services that the server is to
provide. See smb.conf for more information. The default configuration file
name is determined at compile time.
-S server
Name of target server. You should specify either this option or a target
workgroup or a target IP address.
-l
-P
Make queries to the external server using the machine account of the local
server.
--request-timeout 30
level is an integer from 0 to 10. The default value if this parameter is not
specified is 0.
The higher this value, the more detail will be logged to the log files about the
activities of the server. At level 0, only critical errors and serious warnings will
be logged. Level 1 is a reasonable level for day-to-day running - it generates a
small amount of information about operations carried out.
Levels above 1 will generate considerable amounts of log data, and should only
be used when investigating a problem. Levels above 3 are designed for use only
by developers and generate HUGE amounts of log data, most of which is
extremely cryptic.
Note that specifying this parameter here will override the parameter in the
smb.conf file.
COMMANDS
CHANGESECRETPW
This command allows the Samba machine account password to be set from an external
application to a machine account password that has already been stored in Active
Directory. DO NOT USE this command unless you know exactly what you are doing.
The use of this command requires that the force flag (-f) be used also. There will be NO
command prompt. Whatever information is piped into stdin, either by typing at the
command line or otherwise, will be stored as the literal machine password. Do NOT use
this without care and attention as it will overwrite a legitimate machine password
without warning. YOU HAVE BEEN WARNED.
TIME
The NET TIME command allows you to view the time on a remote server or synchronise
the time on the local server with the time on the remote server.
TIME
Without any options, the NET TIME command displays the time on the remote server.
TIME SYSTEM
Displays the time on the remote server in a format ready for /bin/date.
TIME SET
Tries to set the date and time of the local server to that on the remote server using
/bin/date.
TIME ZONE
Displays the timezone in hours from GMT on the remote computer.
[RPC|ADS] JOIN [TYPE] [-U username[%password]] [createupn=UPN]
[createcomputer=OU] [options]
Join a domain. If the account already exists on the server, and [TYPE] is MEMBER, the
machine will attempt to join automatically. (Assuming that the machine has been
created in server manager) Otherwise, a password will be prompted for, and a new
account may be created.
[TYPE] may be PDC, BDC or MEMBER to specify the type of server joining the
domain.
[UPN] (ADS only) set the principalname attribute during the join. The default format is
host/netbiosname@REALM.
[OU] (ADS only) Precreate the computer account in a specific OU. The OU string reads
from top to bottom without RDNs, and is delimited by a '/'. Please note that '\' is used
for escape by both the shell and ldap, so it may need to be doubled or quadrupled to
pass through, and it is not used as a delimiter.
[RPC|ADS] USER
[RPC|ADS] USER
List all users
[RPC|ADS] USER ADD name [password] [-F user flags] [-C comment]
Add specified user.
[RPC|ADS] GROUP
[RAP|RPC] SHARE
[RPC|RAP] FILE
[RPC|RAP] FILE
List all open files on remote server.
SESSION
RAP SESSION
Without any other options, SESSION enumerates all active SMB/CIFS sessions on the
target server.
RAP DOMAIN
Lists all domains and workgroups visible on the current network.
RAP PRINTQ
Note
Currently NOT implemented.
RAP GROUPMEMBER
Note
Currently NOT implemented.
RAP SERVICE
Note
Currently NOT implemented.
LOOKUP
LOOKUP DC [DOMAIN]
Give IP's of Domain Controllers for specified DOMAIN. Defaults to local domain.
CACHE
Samba uses a general caching interface called 'gencache'. It can be controlled using
'NET CACHE'.
s - Seconds
m - Minutes
h - Hours
d - Days
w - Weeks
CACHE LIST
List all current items in the cache.
CACHE FLUSH
Remove all the current items from the cache.
GETLOCALSID [DOMAIN]
Prints the SID of the specified domain, or if the parameter is omitted, the SID of the
local server.
SETLOCALSID S-1-5-21-x-y-z
Sets SID for the local server to the specified SID.
GETDOMAINSID
Prints the local machine SID and the SID of the current domain.
SETDOMAINSID
Sets the SID of the current domain.
GROUPMAP
Manage the mappings between Windows group SIDs and UNIX groups. Common
options include:
GROUPMAP DELETE
Delete a group mapping entry. If more than one group name matches, the first entry
found is deleted.
GROUPMAP MODIFY
Update en existing group entry.
GROUPMAP LIST
List existing group mapping entries.
MAXRID
Prints out the highest RID currently in use on the local server (by the active 'passdb
backend').
RPC INFO
Print information about the domain of the remote server, such as domain name, domain
sid and number of users and groups.
[RPC|ADS] TESTJOIN
Check whether participation in a domain is still valid.
[RPC|ADS] CHANGETRUSTPW
Force change of domain trust password.
RPC TRUSTDOM
RPC RIGHTS
This subcommand is used to view and manage Samba's rights assignments (also
referred to as privileges). There are three options currently available: list, grant, and
revoke. More details on Samba's privilege model and its use can be found in the
Samba-HOWTO-Collection.
RPC ABORTSHUTDOWN
Abort the shutdown of a remote server.
-r
-f
-t timeout
Timeout before system will be shut down. An interactive user of the system can
use this time to cancel the shutdown.
-C message
RPC VAMPIRE
Export users, aliases and groups from remote server to local server. You need to run this
against the PDC, from a Samba machine joined as a BDC.
RPC GETSID
Fetch domain SID and store it in the local secrets.tdb.
ADS LEAVE
Make the remote host leave the domain it is part of.
ADS STATUS
Print out status of machine account of the local machine in ADS. Prints out quite some
debug info. Aimed at developers, regular users should use NET ADS TESTJOIN.
ADS PRINTER
ADS WORKGROUP
Print out workgroup name for specified kerberos realm.
SAM PROVISION
Only available if ldapsam:editposix is set and winbindd is running. Properly populates
the ldap tree with the basic accounts (Administrator) and groups (Domain Users,
Domain Admins, Domain Guests) on the ldap tree.
USERSHARE
Starting with version 3.0.23, a Samba server now supports the ability for non-root users
to add user defined shares to be exported using the "net usershare" commands.
To set this up, first set up your smb.conf by adding to the [global] section: usershare
path = /usr/local/samba/lib/usershares Next create the directory
/usr/local/samba/lib/usershares, change the owner to root and set the group owner to the
UNIX group who should have the ability to create usershares, for example a group
called "serverops". Set the permissions on /usr/local/samba/lib/usershares to 01770.
(Owner and group all access, no access for others, plus the sticky bit, which means that
a file in that directory can be renamed or deleted only by the owner of the file). Finally,
tell smbd how many usershares you will allow by adding to the [global] section of
smb.conf a line such as : usershare max shares = 100. To allow 100 usershare
definitions. Now, members of the UNIX group "serverops" can create user defined
shares on demand using the commands below.
net usershare add sharename path [comment [acl] [guest_ok=[y|n]]] - to add or change a user
defined share.
net usershare info [-l|--long] [wildcard sharename] - to print info about a user defined share.
net usershare list [-l|--long] [wildcard sharename] - to list user defined shares.
"path" specifies the absolute pathname on the system to be exported. Restrictions may
be put on this, see the global smb.conf parameters: "usershare owner only", "usershare
prefix allow list", and "usershare prefix deny list".
The optional "comment" parameter is the comment that will appear on the share when
browsed to by a client.
The optional "acl" field specifies which users have read and write access to the entire
share. Note that guest connections are not allowed unless the smb.conf parameter
"usershare allow guests" has been set. The definition of a user defined share acl is:
"user:permission", where user is a valid username on the system and permission can be
"F", "R", or "D". "F" stands for "full permissions", ie. read and write permissions. "D"
stands for "deny" for a user, ie. prevent this user from accessing this share. "R" stands
for "read only", ie. only allow read access to this share (no creation of new files or
directories or writing to files).
The default if no "acl" is given is "Everyone:R", which means any authenticated user
has read-only access.
The optional "guest_ok" has the same effect as the parameter of the same name in
smb.conf, in that it allows guest access to this user defined share. This parameter is only
allowed if the global parameter "usershare allow guests" has been set to true in the
smb.conf.
There is no separate command to modify an existing user defined share, just use the "net
usershare add [sharename]" command using the same sharename as the one you wish to
modify and specify the new options you wish. The Samba smbd daemon notices user defined
share modifications at connect time so will see the change immediately, there is no need to
restart smbd on adding, deleting or changing a user defined share.
net usershare info on its own dumps out info on the user defined shares that were
created by the current user, or restricts them to share names that match the given
wildcard pattern ('*' matches one or more characters, '?' matches only one character). If
the '-l' or '--long' option is also given, it prints out info on user defined shares created by
other users.
net usershare list on its own list out the names of the user defined shares that were
created by the current user, or restricts the list to share names that match the given
wildcard pattern ('*' matches one or more characters, '?' matches only one character). If
the '-l' or '--long' option is also given, it includes the names of user defined shares
created by other users.
CONF
Starting with version 3.2.0, a Samba server can be configured by data stored in registry.
This configuration data can be edited with the new "net conf" commands.
The deployment of this configuration data can be activated in two levels from the
smb.conf file: Share definitions from registry are activated by setting registry shares
to “yes” in the [global] section and global configuration options are activated by setting
include = registry in the [global] section for a mixed configuration or by setting config
backend = registry in the [global] section for a registry-only configuration. See the
smb.conf(5) manpage for details.
net conf list - Dump the complete configuration in smb.conf like format.
CONF LIST
Print the configuration data stored in the registry in a smb.conf-like format to standard
output.
CONF LISTSHARES
List the names of the shares defined in registry.
CONF DROP
Delete the complete configuration data from registry.
Note that due to the nature of the registry database and the nature of include directives,
the includes need special treatment: Parameters are stored in registry by the parameter
name as valuename, so there is only ever one instance of a parameter per share. Also, a
specific order like in a text file is not guaranteed. For all real parameters, this is
perfectly ok, but the include directive is rather a meta parameter, for which, in the
smb.conf text file, the place where it is specified between the other parameters is very
important. This can not be achieved by the simple registry smbconf data model, so there
is one ordered list of includes per share, and this list is evaluated after all the parameters
of the share.
Further note that currently, only files can be included from registry configuration. In the
future, there will be the ability to include configuration data from other registry keys.
EVENTLOG
Starting with version 3.4.0 net can read, dump, import and export native win32 eventlog
files (usually *.evt). evt files are used by the native Windows eventviewer tools.
The import and export of evt files can only succeed when eventlog list is used in
smb.conf file. See the smb.conf(5) manpage for details.
net eventlog import - Import a eventlog *.evt into the samba internal tdb based representation
of eventlogs.
net eventlog export - Export the samba internal tdb based representation of eventlogs into an
eventlog *.evt file.
DOM
Starting with version 3.2.0 Samba has support for remote join and unjoin APIs, both
client and server-side. Windows supports remote join capabilities since Windows 2000.
In order for Samba to be joined or unjoined remotely an account must be used that is
either member of the Domain Admins group, a member of the local Administrators
group or a user that is granted the SeMachineAccountPrivilege privilege.
The client side support for remote join is implemented in the net dom commands which
are:
DOMAIN can be a NetBIOS domain name (also known as short domain name) or
a DNS domain name for Active Directory Domains. As in Windows, it is also
possible to control which Domain Controller to use. This can be achieved by
appending the DC name using the \ separator character. Example: MYDOM\
MYDC. The DOMAIN parameter cannot be NULL.
OU can be set to a RFC 1779 LDAP DN, like
ou=mymachines,cn=Users,dc=example,dc=com in order to create the machine
account in a non-default LDAP containter. This optional parameter is only
supported when joining Active Directory Domains.
ACCOUNT defines a domain account that will be used to join the machine to the
domain. This domain account needs to have sufficient privileges to join
machines.
PASSWORD defines the password for the domain account defined with ACCOUNT.
REBOOT is an optional parameter that can be set to reboot the remote machine
after successful join to the domain.
Note that you also need to use standard net parameters to connect and authenticate to
the remote machine that you want to join. These additional parameters include: -S
computer and -U user.
This example would connect to a computer named XP as the local administrator using
password secret, and join the computer into a domain called MYDOM using the
MYDOM domain administrator account and password topsecret. After successful join,
the computer would reboot.
DOM UNJOIN account=ACCOUNT password=PASSWORD reboot
Unjoins a computer from a domain. This command supports the following additional
parameters:
ACCOUNT defines a domain account that will be used to unjoin the machine from
the domain. This domain account needs to have sufficient privileges to unjoin
machines.
PASSWORD defines the password for the domain account defined with ACCOUNT.
REBOOT is an optional parameter that can be set to reboot the remote machine
after successful unjoin from the domain.
Note that you also need to use standard net parameters to connect and authenticate to
the remote machine that you want to unjoin. These additional parameters include: -S
computer and -U user.
This example would connect to a computer named XP as the local administrator using
password secret, and unjoin the computer from the domain using the MYDOM domain
administrator account and password topsecret. After successful unjoin, the computer
would reboot.
Note that you also need to use standard net parameters to connect and authenticate to
the remote machine that you want to rename in the domain. These additional parameters
include: -S computer and -U user.
This example would connect to a computer named XP as the local administrator using
password secret, and rename the joined computer to XPNEW using the MYDOM
domain administrator account and password topsecret. After successful rename, the
computer would reboot.
G_LOCK
Manage global locks.
G_LOCK LOCKS
Print a list of all currently existing locknames.
HELP [COMMAND]
Gives usage information for the specified command.
VERSION
This man page is complete for version 3 of the Samba suite.
AUTHOR
The original Samba software and related utilities were created by Andrew Tridgell.
Samba is now developed by the Samba Team as an Open Source project similar to the
way the Linux kernel is developed.