Search code examples
phpldap

How to add external home directory


I have a script running which makes users in Active Directory, However the home directories of our employees are on a server. If I try to set the home directory it will only make a local home directory and not a network one.

$ldaprecord['homedirectory'] = $network_path_to_homedirectory;

This is how I set the attribute but it is not doing what I hoped for.

EDIT

This is how it is getting set now. enter image description here

But it needs to look likes this: enter image description here

The variable $ldaprecord is populated like this:

$ldaprecord['cn'] = $firstname ." ". $lastname;
$ldaprecord['givenName'] = $firstname;
$ldaprecord['sn'] = $lastname;
$ldaprecord['mail'] = $email;
$ldaprecord['userprincipalname'] = $email;
$ldaprecord['samaccountname'] = $shortname;
$ldaprecord['objectclass'][0] = "top";
$ldaprecord['homedirectory'] = "H:\\aponl.local\Shares\Userhome\".$shortname;
$ldaprecord['userAccountControl'] = 544;


Solution

  • The documentation for the homeDirectory attribute gives you the answer:

    If homeDrive is set and specifies a drive letter, homeDirectory must be a UNC path. Otherwise, homeDirectory is a fully qualified local path including the drive letter (for example, DriveLetter**:\Directory**Folder).

    In other words, whether it's considered local or remote will depend on the value of the homeDrive attribute.

    So this is what you're looking for:

    $ldaprecord['homeDirectory'] = "\\\\aponl.local\\Shares\\Userhome\\" . $shortname;
    $ldaprecord['homeDrive'] = "H:";