UAC e Mappatura drive di rete in script di logon

Con la UAC gli script di login utente per la mappatura di drive di rete potrebbero non funzionare come descritto nel seguente After you turn on User Account Control in Windows Vista, programs may be unable to access some network locations.

This problem occurs because User Account Control treats members of the Administrators group as standard users. Therefore, network shares that are mapped by logon scripts are shared with the standard user access token instead of with the full administrator access token.

When a member of the Administrators group logs on to a Windows Vista-based computer that has User Account Control enabled, the user runs as a standard user. Standard users are members of the Users group.

When an administrator logs on to Windows Vista, the Local Security Authority (LSA) creates two access tokens. If LSA is notified that the user is a member of the Administrators group, LSA creates the second logon that has the administrator rights removed (filtered). This filtered access token is used to start the user’s desktop. Applications can use the full administrator access token if the administrator user clicks Allow in a User Account Control dialog box.

When network shares are mapped, they are linked to the current logon session for the current process access token. This means that, if a user uses the command prompt (Cmd.exe) together with the filtered access token to map a network share, the network share is not mapped for processes that run with the full administrator access token.

Nella KB viene proposto come workaround quello di creare la chiave di registry KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLinkedConnections di tipo DWORD e impostarla a 1 e quindi riavviare il  computer.

Va però precisato che questa impostazione rende il sistema meno sicuro e non è supportata da Microsoft:

This workaround may make your system unsafe. Microsoft does not support this workaround. Use this workaround at your own risk

This value enables Windows Vista to share network connections between the filtered access token and the full administrator access token for a member of the Administrators group. After you configure this registry value, LSA checks whether there is another access token that is associated with the current user session if a network resource is mapped to an access token. If LSA determines that there is a linked access token, it adds the network share to the linked location.

Si noti che il tutto nasce dalla contemporaneità di due fattori ovvero UAC abilitata e l’utilizzo di account appartenente al gruppo degli amministratori locali.

Un’altra soluzione sarebbe la disabilitazione della UAC, ma in questo la cura sarebbe peggiore del male perchè ci ritroveremmo un sistema utilizzato con privilegi di amministratore locale senza neppure la protezione della UAC.

La soluzione ottimale è evitare che l’account sia membro del gruppo degli amministratori locali in questo modo la mappatura viene eseguita correttamente.