Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

VBScript Logon Script to Set Users HomeDirectory/HomeDrive Attributes

$
0
0

Hi all,

I'm trying to write a logon script that checks if the user logging on has a home directory, and if not, create one. The problem I'm having is that as the script is running under the user context, they obviously don't have write permissions to AD. Is there any way this could work, perhaps by some sort of impersonation in the script? Alternatively if anyone has any better suggestions as to a better way to achieve this I'm more than open to suggestions!

Here is the code I have currently if it helps;

Set oADInfo = CreateObject("ADSystemInfo")
sDN = oADInfo.UserName

Set oUser = GetObject("LDAP://" & sDN)
sUserName = oUser.sAMAccountName
sHomeDir = oUser.homeDirectory

If sHomeDir = "" Then
	sHomeDir = "\\fileserver\users\" & sUserName

	oUser.Put "homeDirectory", sHomeDir
	oUser.Put "homeDrive", "F:"
	oUser.SetInfo
End If

Many thanks,

James




Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>