When I create an account using vbscript I also create the home dir for the
user and populate the homeDir properties of the account. There are no errors
creating the directory and there are no errors populating the homeDir
property of the account. Using Active Directory Users and Computer (ADUC) I
can see that the account was created and that the home dir was set properly.
Checking the drive for the dir reveals it is created and the rights are
assigned correctly.

The problem is at login. When you login with one of these accounts the user
does not get a mapping to their home dir. Yet if they use the run cmd they
can open the dir and utilize it.

We suspect it has something to do with what gets input to the homeDir
property but I'm unable to determine that there is anything wrong with it.

Interestingly if I modify the home dir property in ADUC (so the apply button
becomes active) and then switch it back to what was there then click apply,
when the user logs in their home dir appears correctly for them.

Any ideas?

Re: Missing home dir when account created by vbscript by Richard

Richard
Wed May 10 13:48:15 CDT 2006

Kevin wrote:

> When I create an account using vbscript I also create the home dir for the
> user and populate the homeDir properties of the account. There are no
> errors
> creating the directory and there are no errors populating the homeDir
> property of the account. Using Active Directory Users and Computer (ADUC)
> I
> can see that the account was created and that the home dir was set
> properly.
> Checking the drive for the dir reveals it is created and the rights are
> assigned correctly.
>
> The problem is at login. When you login with one of these accounts the
> user
> does not get a mapping to their home dir. Yet if they use the run cmd they
> can open the dir and utilize it.
>
> We suspect it has something to do with what gets input to the homeDir
> property but I'm unable to determine that there is anything wrong with it.
>
> Interestingly if I modify the home dir property in ADUC (so the apply
> button
> becomes active) and then switch it back to what was there then click
> apply,
> when the user logs in their home dir appears correctly for them.
>
> Any ideas?

Are you using the LDAP provider and assigning values to the homeDrive and
homeDirectory attributes? Also, the homeDrive attribute should be a single
letter followed by a colon, such as "H:".

If you are using the WinNT provider, the attributes are homeDirDrive and
homeDirectory.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net



Re: Missing home dir when account created by vbscript by Kevin

Kevin
Wed May 10 14:06:01 CDT 2006

"Richard Mueller" wrote:
> Are you using the LDAP provider and assigning values to the homeDrive and
> homeDirectory attributes? Also, the homeDrive attribute should be a single
> letter followed by a colon, such as "H:".
>
> If you are using the WinNT provider, the attributes are homeDirDrive and
> homeDirectory.
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net

Richard,

Thanks for the reply, I begin a for loop with this code:
On Error Resume Next
Set objUser = GetObject("LDAP://" & DN)
If Err.Number <> 0 Then
sMsg = sMsg & Err.Number & vbcrlf
sMsg = sMsg & Err.Description & vbcrlf
sMsg = sMsg & "ERROR: Error binding to: " & DN & vbcrlf
bError = True
Err.Number = 0
End If
Set objClass = GetObject(objUser.Schema)
For Each property in objClass.OptionalProperties
objUser.GetInfo

Then using Select Case I alter the properties like this:
Select Case LCase(property)
Case LCase("homeDrive")
objUser.put "homeDrive", HomeDrive
If Err.Number <> 0 Then
sMsg = sMsg & Err.Number & vbcrlf
sMsg = sMsg & Err.Description & vbcrlf
sMsg = sMsg & "ERROR: objUser.put homeDrive" & vbcrlf
bError = True
Err.Number = 0
End If
objUser.SetInfo
If Err.Number <> 0 Then
sMsg = sMsg & Err.Number & vbcrlf
sMsg = sMsg & Err.Description & vbcrlf
sMsg = sMsg & "ERROR: objUser.SetInfo homeDrive" & vbcrlf
bError = True
Err.Number = 0
End If
Case LCase("homeDirectory")
objUser.put "homeDirectory", HomeDir
If Err.Number <> 0 Then
sMsg = sMsg & Err.Number & vbcrlf
sMsg = sMsg & Err.Description & vbcrlf
sMsg = sMsg & "ERROR: objUser.put homeDirectory" & vbcrlf
bError = True
Err.Number = 0
End If
objUser.SetInfo
If Err.Number <> 0 Then
sMsg = sMsg & Err.Number & vbcrlf
sMsg = sMsg & Err.Description & vbcrlf
sMsg = sMsg & "ERROR: objUser.SetInfo homeDirectory" & vbcrlf
bError = True
Err.Number = 0
End If

I was finding that four properties were not updating so I moved the .GetInfo
inside of the for loop and ended up adding a .SetInfo to each case. Now those
four properties get updated. As I mentioned in my original post there are no
errors when this executes.

Re: Missing home dir when account created by vbscript by Richard

Richard
Wed May 10 14:59:46 CDT 2006

Hi,

I don't see the problem, but it's hard to say with "On Error Resume Next"
used throughout. There seems to be no need to use the Schema method to
enumerate all properties, since you address them explicitly when you assign
values. I would suggest:

Set objUser = GetObject("LDAP://" & DN)
objUser.Put "homeDrive", HomeDrive
objUser.Put "homeDirectory", HomeDir
On Error Resume Next
objUser.SetInfo
If (Err.Number <> 0) Then
On Error GoTo 0
sMsg = sMsg & Err.Number & vbCrLf
sMsg = sMsg & Err.Description & vbCrLf
sMsg = sMsg & "ERROR: SetInfo failed" & vbCrLf
bError = True
End If
On Error GoTo 0

Only one SetInfo is needed. The disadvantage is that if there is an error,
you don't know which attribute raised the error. You can invoke SetInfo
after every value is assigned, but it seems wasteful, although that could
help isolate a problem. I turn off normal error handling only for statements
I expect could raise an error, then restore normal error handling. In the
above, for example, if the "Set objUser" statement raises an error,
execution will halt, but you will get an error message with a line number,
so you know what happened. And, if that Set objUser failed, there's little
point continueing.

From what you say, the attributes are assigned values (since you see them in
ADUC), they just don't seem to be used until you re-assign them in ADUC. By
testing, I find that if you assign "K" for homeDrive, no error is raised and
ADUC shows the value "K:". If you retrieve the value for homeDrive in code,
however, it is "K". I remember testing in the past and finding that this
does not work, it should be "K:" with the trailing colon. My best guess is
that your variable HomeDrive lacks the trailing colon.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net

"Kevin" <Kevin@discussions.microsoft.com> wrote in message
news:7AC353DA-DA72-49CA-B865-13A817DA5F2F@microsoft.com...
> "Richard Mueller" wrote:
>> Are you using the LDAP provider and assigning values to the homeDrive and
>> homeDirectory attributes? Also, the homeDrive attribute should be a
>> single
>> letter followed by a colon, such as "H:".
>>
>> If you are using the WinNT provider, the attributes are homeDirDrive and
>> homeDirectory.
>>
>> --
>> Richard
>> Microsoft MVP Scripting and ADSI
>> Hilltop Lab - http://www.rlmueller.net
>
> Richard,
>
> Thanks for the reply, I begin a for loop with this code:
> On Error Resume Next
> Set objUser = GetObject("LDAP://" & DN)
> If Err.Number <> 0 Then
> sMsg = sMsg & Err.Number & vbcrlf
> sMsg = sMsg & Err.Description & vbcrlf
> sMsg = sMsg & "ERROR: Error binding to: " & DN & vbcrlf
> bError = True
> Err.Number = 0
> End If
> Set objClass = GetObject(objUser.Schema)
> For Each property in objClass.OptionalProperties
> objUser.GetInfo
>
> Then using Select Case I alter the properties like this:
> Select Case LCase(property)
> Case LCase("homeDrive")
> objUser.put "homeDrive", HomeDrive
> If Err.Number <> 0 Then
> sMsg = sMsg & Err.Number & vbcrlf
> sMsg = sMsg & Err.Description & vbcrlf
> sMsg = sMsg & "ERROR: objUser.put homeDrive" & vbcrlf
> bError = True
> Err.Number = 0
> End If
> objUser.SetInfo
> If Err.Number <> 0 Then
> sMsg = sMsg & Err.Number & vbcrlf
> sMsg = sMsg & Err.Description & vbcrlf
> sMsg = sMsg & "ERROR: objUser.SetInfo homeDrive" & vbcrlf
> bError = True
> Err.Number = 0
> End If
> Case LCase("homeDirectory")
> objUser.put "homeDirectory", HomeDir
> If Err.Number <> 0 Then
> sMsg = sMsg & Err.Number & vbcrlf
> sMsg = sMsg & Err.Description & vbcrlf
> sMsg = sMsg & "ERROR: objUser.put homeDirectory" & vbcrlf
> bError = True
> Err.Number = 0
> End If
> objUser.SetInfo
> If Err.Number <> 0 Then
> sMsg = sMsg & Err.Number & vbcrlf
> sMsg = sMsg & Err.Description & vbcrlf
> sMsg = sMsg & "ERROR: objUser.SetInfo homeDirectory" & vbcrlf
> bError = True
> Err.Number = 0
> End If
>
> I was finding that four properties were not updating so I moved the
> .GetInfo
> inside of the for loop and ended up adding a .SetInfo to each case. Now
> those
> four properties get updated. As I mentioned in my original post there are
> no
> errors when this executes.



Re: Missing home dir when account created by vbscript by Kevin

Kevin
Wed May 10 17:21:02 CDT 2006

"Richard Mueller" wrote:
> Hi,
>
> I don't see the problem, but it's hard to say with "On Error Resume Next"
> used throughout. There seems to be no need to use the Schema method to
> enumerate all properties, since you address them explicitly when you assign
> values. I would suggest:
>
> Set objUser = GetObject("LDAP://" & DN)
> objUser.Put "homeDrive", HomeDrive
> objUser.Put "homeDirectory", HomeDir
> On Error Resume Next
> objUser.SetInfo
> If (Err.Number <> 0) Then
> On Error GoTo 0
> sMsg = sMsg & Err.Number & vbCrLf
> sMsg = sMsg & Err.Description & vbCrLf
> sMsg = sMsg & "ERROR: SetInfo failed" & vbCrLf
> bError = True
> End If
> On Error GoTo 0
>
> Only one SetInfo is needed. The disadvantage is that if there is an error,
> you don't know which attribute raised the error. You can invoke SetInfo
> after every value is assigned, but it seems wasteful, although that could
> help isolate a problem. I turn off normal error handling only for statements
> I expect could raise an error, then restore normal error handling. In the
> above, for example, if the "Set objUser" statement raises an error,
> execution will halt, but you will get an error message with a line number,
> so you know what happened. And, if that Set objUser failed, there's little
> point continueing.
>
> From what you say, the attributes are assigned values (since you see them in
> ADUC), they just don't seem to be used until you re-assign them in ADUC. By
> testing, I find that if you assign "K" for homeDrive, no error is raised and
> ADUC shows the value "K:". If you retrieve the value for homeDrive in code,
> however, it is "K". I remember testing in the past and finding that this
> does not work, it should be "K:" with the trailing colon. My best guess is
> that your variable HomeDrive lacks the trailing colon.
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net

Richard,

Thanks, it was in fact the drive designation. The input file was missing the
":". As for the numerous .SetInfo, I found that I had to have them or
multiple properties did not get set even though there were no errors
reported. Perhaps it was the home drive that was causing that, I'll review it
and retest it to see if I can go back to a single .SetInfo.

Thanks for your help.