I have written a script for mapping network drives based on which groups a user is a member of.
The script works well, when I am in the office. But if I boot the PC when it isn't on the network and log in, then attach to the network (either in the office or over VPN), the script fails.
Is the information in Security.Principal.NTAccount only filled in, when the user logs on when attached to the network?
The problem I am trying to solve is the following:
- in the office, the PCs automatically connect the correct network drives based on group policy.
- If the user is on the move and signs in over VPN, they don't have any of their mapped drives.
- each user has a different set of network drives (only P: is common to all users, their personal directory).
- the script works through all of the groups that the user is a member of and attaches the relevant drive for each group.
As stated above, this works fine, if the user logs in when on the network (when they don't actually need the script - you have to first remove all mapped drives to test the script!), but if they log on offline, then attach to the network, the script fails.
Edit: It works if I disconnect the PC in the office and reboot. If I am at home and connect over VPN it doesn't work - error translates to roughly "clients credentials couldn't be confirmed by the domain".