ユーザーホームフォルダ

提供:雑廉堂Wiki

はじめに

ホームフォルダには、個々のアカウントのファイルが含まれています。Sambaを使用すると、ネットワークユーザーが自分のファイルを、ファイルサーバー上の自分のホームフォルダーに保存できるように、ディレクトリを共有できます。

このドキュメントでは、\\server\user_name\パスを使用して、ユーザーのホームディレクトリを動的に共有する、Sambaのビルトインの[homes]セクションを使用しません。これは特定のシナリオでは役に立ちますが、いくつかの欠点があります。

  • Windowsはこの機能をサポートしていません。また、Active Directory(AD)でのフォルダリダイレクトなどの特定の設定では代わりに回避策が必要になり、公式のソリューションを使用できません。
  • 新しい各ユーザーのホームディレクトリを手動で作成する必要があります。
  • [homes]はActive Directory (AD) ドメインコントローラ(DC)上での実行はサポートされていません。

以下では、ホームフォルダを含んでいるディレクトリは、共有名usersを使用して共有されます。各ユーザーのホームディレクトリは、\\server\users\user_nameのような感じで、\\server\users\共有のサブディレクトリとして作成されます。これはMicrosoft Windowsの環境で使われているのと同じフォーマットであり、追加の設定を要しません。

Sambaファイルサーバーで共有を設定する

WindowsのACLを使う

ホームディレクトリをホストする共有に、拡張アクセスコントロールリスト(ACL)を設定することは、手動でユーザーのホームフォルダを作成、アクセス許可を設定することなしに、Active Directory ユーザーとコンピュータに新しいユーザーを作成することを可能にします。

Sambaファイルサーバー上でユーザーのホームフォルダーをホストするための共有を作成するには、たとえばusersを使用します:

  • 共有の権限:
Principal Access
Domain Users Change
Domain Admins Full Control
  • users共有のルートのファイルシステムのアクセス許可:
Principal Access Applies to
Domain Users* Read & execute This folder only
CREATOR OWNER Full control Subfolders and files only
Domain Admins Full control This folder, subfolders and files
* グループのメンバーがユーザーのプロファイルをその共有に格納することを可能にするために、別のグループを設定することもできます。異なるグループを使用する場合は、前の例のDomain Usersに表示されているように権限を適用してください。
共有のルートで権限の継承が無効になっていることを確認します。[セキュリティの詳細設定]ウィンドウの許可エントリに継承元列にパスが表示されている場合は、[継承を無効にする]ボタンをクリックします。 Windows 7では、このオブジェクトの親からの継承可能なアクセス許可を含めるチェックボックスをオフにして、同じ設定を設定します。
Samba共有では、ファイルシステムACLのSYSTEMアカウントを省略できます。詳細は、The SYSTEM Accountを参照してください。

これらの設定により、Domain Adminsグループのメンバーは、Active Directoryユーザーとコンピュータアプリケーションでユーザーのホームフォルダを設定できます。これにより、ホームフォルダが自動的に作成され、正しいアクセス許可が設定されます。

POSIX ACLを使用する

Windowsのアクセス制御リスト(ACL)を使用する代わりに、SambaサーバーでPOSIX ACLを使用して共有を設定できます。 ただし、POSIX ACLを使用して権限を設定する場合は、新しいユーザーごとにホームディレクトリを手動で作成し、権限を設定する必要があります。

{{#invoke:Message box|imbox}}

たとえば、users共有を作成するには:

  • smb.confファイルに次の共有設定セクションを追加します:
 [users]
         path = /srv/samba/users/
         read only = no
         force create mode = 0600
         force directory mode = 0700
使用されるパラメータの詳細については、smb.conf(5) のマニュアルページの説明を参照してください。
共有の名前としてhomesを使用しないでください。 詳細については、 はじめにを参照してください。
  • ディレクトリを作成し、正しい権限を設定してください:
# mkdir -p /srv/samba/users/
# chgrp -R "Domain Users" /srv/samba/users/
# chmod 2750 /srv/samba/users/
ドメインでは、 Domain Users グループはグループで、すべてのドメインユーザーアカウントがそのメンバーです。 あるいは、ドメイン以外の環境を実行している場合は、ローカルに存在する任意のグループに設定できます。 ただし、共有にアクセスするには、ユーザーアカウントがこのグループのメンバーである必要があります。
  • Sambaをリロード:
# smbcontrol all reload-config

新しいユーザのホームフォルダを作成する

Windows ACLを使用する

Active Directoryユーザーとコンピュータアプリケーションを使用している場合は、ユーザーのホームディレクトリが自動的に作成され、アプリケーションでユーザーフォルダへのパスを設定すると正しいアクセス許可が適用されます。 Active Directoryユーザーとコンピュータを使用していない場合は、フォルダを手動で作成して正しい権限を設定する必要があります。 例えば;

  • \\server\users\共有に新しいフォルダを作成する権限を持つアカウントを使用してWindowsマシンにログインします。
  • \\server\users\共有に移動します。
  • ユーザーの新しいホームフォルダを作成します。
  • フォルダのアクセス制御リスト(ACL)にユーザを追加し、そのユーザにフルコントロールを付与します。 詳細については、フォルダへのACLの設定を参照してください。

POSIX ACLを使用する

POSIXアクセスコントロールリスト(ACL)を使用してusers共有を設定するときは、新しいユーザーごとにホームフォルダを手動で作成する必要があります。 demoユーザーのホームフォルダを作成するには:

  • ディレクトリを作成:
# mkdir /srv/samba/users/demo/
  • 次の権限を設定して、demoユーザーのみがディレクトリにアクセスできるようにします:
# chown user_name /srv/samba/users/demo/
# chmod 700 /srv/samba/users/demo/

ホームフォルダをユーザに割り当てる

Active Directoryの場合

Active Directoryユーザーとコンピュータを使用する

Active Directoryでは、Active Directoryユーザーとコンピュータ Windowsアプリケーションを使用して、ユーザーのホームフォルダへのパスと割り当てられたドライブ文字を設定できます。 リモートサーバー管理ツール(RSAT)がインストールされていない場合は、 RSATのインストールを参照してください。

\\server\users\demo\パスをホームフォルダとしてdemoアカウントに割り当てるには:

  • ユーザーアカウントを編集できるアカウントを使用してコンピューターにログインします。
  • Active Directoryユーザーとコンピュータアプリケーションを開きます。
  • demoアカウントを含むディレクトリコンテナに移動します。
  • demoユーザーアカウントを右クリックして、プロパティを選択します。
  • [プロフィール]タブをクリックします。
  • [Connect]を選択します。Windowsがマップされたホームフォルダを割り当て、Toフィールドにホームフォルダへのパスを入力します。
.
  • OKをクリック

ホームフォルダが作成されていないという設定を保存するときに警告が表示された場合:

  • Windowsのアクセス制御リスト(ACL)を使用して共有を設定すると、users共有のアクセス許可が正しく設定されませんでした。 この問題を解決するには、 Windows ACLの使用で説明されている権限を設定します。
  • あなたはPOSIX ACLを使って共有を設定した。 問題を解決するには、ディレクトリを手動で作成してください。 新規ユーザーのホームフォルダーの作成 - POSIX ACLの使用を参照してください。

グループポリシー設定を使用する

グループポリシー設定を使用して、設定を組織単位(OU)またはドメインに割り当てることができます。これにより、たとえば、OUまたはドメイン内のすべてのユーザーにホームフォルダパスを自動的に割り当てることができます。アカウントを別のOUまたはドメインに移動すると、設定は削除または更新されます。 この方法を使用すると、各ユーザーアカウントに手動で設定を割り当てる必要はありません。

各ユーザーのホームフォルダーとして\\server\users\user_nameパスを自動的に割り当てるドメインのグループポリシーオブジェクト(GPO)を作成するには、次の手順を実行します。

  • ADドメインのAdministratorアカウントなど、グループポリシーを編集できるアカウントを使用してコンピュータにログインします。
  • グループポリシー管理コンソールを開きます。 このコンピュータにリモートサーバー管理ツール(RSAT)がインストールされていない場合は、 RSATのインストールを参照してください。
  • 自分のADドメインを右クリックして[このドメインにGPOを作成し、ここにリンク]を選択します。
  • serverのようにGPOの名前を入力します。 新しいGPOがドメインエントリの下に表示されます。
  • 新しく作成したGPOを右クリックして[編集]を選択し、グループポリシー管理エディタを開きます。
  • ユーザー設定→に移動します。 設定→ Windowsの設定→ ドライブマップエントリ
  • [ドライブマップ]エントリを右クリックして[新規]を選択し、→ 割り当てられたドライブ
  • Set the following:
  • On the General tab:
  • Action: Create
  • Location: \\server\users\%LogonUser%
Windows automatically replaces the %LogonUser% variable when a user logs in
  • Select Reconnect
  • Label: Enter a string. For example: Home
  • Use: Select a drive letter the home folder is mapped to.
  • On the Common tab:
  • Select Run in logged-on user's security context (user policy option)
  • Click OK.
  • Close the Group Policy Management Editor. The GPOs are automatically saved on the Sysvol share on the domain controller (DC).
  • Close the Group Policy Management Console.

The policy is applied to users in the OU or domain, the policy is assigned to, during the next log in.

Using ldbedit on a Domain Controller

On a domain controller (DC), for example, to assign the \\server\users\demo path as home folder to the demo account and set the assigned drive letter to H:

  • Edit the demouser account:
# ldbedit -H /usr/local/samba/private/sam.ldb 'sAMAccountName=demo'
  • The accounts attributes are displayed in an editor. Append the following attributes and values to the end of the list:
homeDrive: H:
homeDirectory: \\server\users\demo\
  • Save the changes.

The setting is applied the next time the user logs in.

In an NT4 Domain

In an Samba NT4 domain, to set \\server\users\%U as path to the home folder and to map the drive to the H: drive letter:

  • Add the following parameters to the [global] section in your smb.conf file:
logon drive = H:
logon home = \\server\users\%U
During logging in to the domain member, Samba automatically replaces the %U variable with the session user name. For further details, see the Variable Substitutions section in the smb.conf(5) man page.
  • Reload Samba:
# smbcontrol all reload-config


In a Non-domain Environment

Using a Windows Professional or Higher Edition

If your Samba server and clients are not part of a domain, set the user home folder mapping in the local user account's properties:

  • Log on to the Windows machine using an account that is member of the local Administrators group.
  • Open the lusrmgr.msc (Local User and Groups) application.
The lusrmgr.msc application is not available in Windows Home editions.
  • Click Users in the navigation on the left side.
  • Right-click the account you want to assign a home folder to, and select Properties
  • Navigate to the Profile tab.
  • Select Connect, the drive letter Windows assigns the mapped home folder to, and enter the path to the home folder into the To field.
  • Click OK.

You must set the mapping for each user on every Windows client manually.


Using Windows Home Edition

Windows Home editions do not provide the necessary application to set the user home folder mapping in the local account properties. Instead each user must map the drive manually:

  • Log on to the Windows machine as the user that should get the home folder mapped
  • Open a command prompt.
  • For example, to map the \\server\users\demo\ folder to the H: drive letter, enter:
> net use H: \\server\users\demo\ /persistent:yes

The user home folder is automatically connected when the user logs in. To stop the automatic mapping, disconnect the drive. For example:

> net use H: /delete