From: Scott Heath Scott on
Background:

I have written a VB6 program to run on Windows PE 1.2 (XP based) to allow
for the selection of specific retail location data during the Point of Sale
deployment process. Using drop-down menus elimiates most mistakes. This app
has worked fine on Windows PE 1.2 for almost 4 years. The last step of the
process is to stage the AD account in the correct OU. I am using this code
to accomplish that task:

Err.Clear
Dim ADCompOU As IADsContainer
Dim NameSpace As IADs
Dim ADCompObj As IADs
Set NameSpace = GetObject("LDAP:")
Set ADCompOU = NameSpace.OpenDSObject(ADBrandPath, ADUserID, ADPassword,
ADS_SECURE_AUTHENTICATION + ADS_SERVER_BIND)
Set ADCompObj = ADCompOU.Create("Computer", "cn=" & CompName)
ADCompObj.Put "sAMAccountName", CompName & "$"
ADCompObj.Put "UserAccountControl", "4128"
ADCompObj.SetInfo
If Err.Number <> 0 Then
MsgBox "Could Not Create AD Object: " & CompName & "." & vbCrLf & _
"Contact Zales Support Team.", vbExclamation
Exit Sub
End If

Now I am moving to Windows PE 3.0 (Windows 7 based) becuase of native SATA
AHCI & RAID support as well as newer NIC drivers that I have had trouble
getting to work on Windows PE 1.2. I have added all the groovy MS packages
for Windows PE 3.0 to cover scripting and I have used a 3rd party INF to add
ADSI support. Unfortunately when the NameSpace.OpenDSObject method is
executed I get a "unknown username or bad password" error. For grins I
copied the same code into a VBScript including the code that sets the
variables, so I know I didn't change anything like a username or password
accidentally. The VBScript executes fine in the same Windows PE 3.0
environment. I open my VB6 app and it fails again.

Does anyone have any ideas?

I thank you all in advance for any help and for suffering through this
extremely long post.

Regards,
Scott Heath
From: Paul Clement on
On Tue, 9 Feb 2010 07:25:02 -0800, Scott Heath <Scott Heath(a)discussions.microsoft.com> wrote:

� Background:

� I have written a VB6 program to run on Windows PE 1.2 (XP based) to allow
� for the selection of specific retail location data during the Point of Sale
� deployment process. Using drop-down menus elimiates most mistakes. This app
� has worked fine on Windows PE 1.2 for almost 4 years. The last step of the
� process is to stage the AD account in the correct OU. I am using this code
� to accomplish that task:

� Err.Clear
� Dim ADCompOU As IADsContainer
� Dim NameSpace As IADs
� Dim ADCompObj As IADs
� Set NameSpace = GetObject("LDAP:")
� Set ADCompOU = NameSpace.OpenDSObject(ADBrandPath, ADUserID, ADPassword,
� ADS_SECURE_AUTHENTICATION + ADS_SERVER_BIND)
� Set ADCompObj = ADCompOU.Create("Computer", "cn=" & CompName)
� ADCompObj.Put "sAMAccountName", CompName & "$"
� ADCompObj.Put "UserAccountControl", "4128"
� ADCompObj.SetInfo
� If Err.Number <> 0 Then
� MsgBox "Could Not Create AD Object: " & CompName & "." & vbCrLf & _
� "Contact Zales Support Team.", vbExclamation
� Exit Sub
� End If

� Now I am moving to Windows PE 3.0 (Windows 7 based) becuase of native SATA
� AHCI & RAID support as well as newer NIC drivers that I have had trouble
� getting to work on Windows PE 1.2. I have added all the groovy MS packages
� for Windows PE 3.0 to cover scripting and I have used a 3rd party INF to add
� ADSI support. Unfortunately when the NameSpace.OpenDSObject method is
� executed I get a "unknown username or bad password" error. For grins I
� copied the same code into a VBScript including the code that sets the
� variables, so I know I didn't change anything like a username or password
� accidentally. The VBScript executes fine in the same Windows PE 3.0
� environment. I open my VB6 app and it fails again.

� Does anyone have any ideas?

� I thank you all in advance for any help and for suffering through this
� extremely long post.

� Regards,
� Scott Heath

Did you copy the VBScript code back to your VB 6.0 program and try running it again? I'm sure there
are some slight differences. I don't see where the constants are defined so I will assume that they
have the correct values.


Paul
~~~~
Microsoft MVP (Visual Basic)
From: Scott Heath Scott on
After tons of trying random things I tried the right random thing. I changed
the format of the username from "domain\username" to "username(a)domain.com"
and magically everything works fine. So weird...

Hope this might help someone else!

Regards,
Scott

"Scott Heath" wrote:

> Background:
>
> I have written a VB6 program to run on Windows PE 1.2 (XP based) to allow
> for the selection of specific retail location data during the Point of Sale
> deployment process. Using drop-down menus elimiates most mistakes. This app
> has worked fine on Windows PE 1.2 for almost 4 years. The last step of the
> process is to stage the AD account in the correct OU. I am using this code
> to accomplish that task:
>
> Err.Clear
> Dim ADCompOU As IADsContainer
> Dim NameSpace As IADs
> Dim ADCompObj As IADs
> Set NameSpace = GetObject("LDAP:")
> Set ADCompOU = NameSpace.OpenDSObject(ADBrandPath, ADUserID, ADPassword,
> ADS_SECURE_AUTHENTICATION + ADS_SERVER_BIND)
> Set ADCompObj = ADCompOU.Create("Computer", "cn=" & CompName)
> ADCompObj.Put "sAMAccountName", CompName & "$"
> ADCompObj.Put "UserAccountControl", "4128"
> ADCompObj.SetInfo
> If Err.Number <> 0 Then
> MsgBox "Could Not Create AD Object: " & CompName & "." & vbCrLf & _
> "Contact Zales Support Team.", vbExclamation
> Exit Sub
> End If
>
> Now I am moving to Windows PE 3.0 (Windows 7 based) becuase of native SATA
> AHCI & RAID support as well as newer NIC drivers that I have had trouble
> getting to work on Windows PE 1.2. I have added all the groovy MS packages
> for Windows PE 3.0 to cover scripting and I have used a 3rd party INF to add
> ADSI support. Unfortunately when the NameSpace.OpenDSObject method is
> executed I get a "unknown username or bad password" error. For grins I
> copied the same code into a VBScript including the code that sets the
> variables, so I know I didn't change anything like a username or password
> accidentally. The VBScript executes fine in the same Windows PE 3.0
> environment. I open my VB6 app and it fails again.
>
> Does anyone have any ideas?
>
> I thank you all in advance for any help and for suffering through this
> extremely long post.
>
> Regards,
> Scott Heath
From: Scott Heath on
Thanks for the response Paul. The variables are defined in another
subroutine based upon environment (PROD\QA\DEV), but I confirmed they were
correct.

I was able to solve the problem by change the username format. I had been
using the classic "domain\username", as I had for years. We are actually
still using Windows Server 2000 DCs. (Bleh!). On a lark I changed it to
"username(a)domain.com" and it fixed the problem. This makes no sense to me
because I am using the same activeds.dll for both the VBScript and VB6 code,
but it will only work one way in VB6 since my change to Windows PE 3.0. I am
guessing that a registry entry somewhere changed that it forcing VB6 to
behave certain way, but I made no custom registry entries between PE 1.2 and
3.0.

In any case, I thank you for your response. If you have any suggestions as
to the cause of this anomoly I'd be interested.

Thanks,
Scott

"Paul Clement" wrote:

> On Tue, 9 Feb 2010 07:25:02 -0800, Scott Heath <Scott Heath(a)discussions.microsoft.com> wrote:
>
> ¤ Background:
> ¤
> ¤ I have written a VB6 program to run on Windows PE 1.2 (XP based) to allow
> ¤ for the selection of specific retail location data during the Point of Sale
> ¤ deployment process. Using drop-down menus elimiates most mistakes. This app
> ¤ has worked fine on Windows PE 1.2 for almost 4 years. The last step of the
> ¤ process is to stage the AD account in the correct OU. I am using this code
> ¤ to accomplish that task:
> ¤
> ¤ Err.Clear
> ¤ Dim ADCompOU As IADsContainer
> ¤ Dim NameSpace As IADs
> ¤ Dim ADCompObj As IADs
> ¤ Set NameSpace = GetObject("LDAP:")
> ¤ Set ADCompOU = NameSpace.OpenDSObject(ADBrandPath, ADUserID, ADPassword,
> ¤ ADS_SECURE_AUTHENTICATION + ADS_SERVER_BIND)
> ¤ Set ADCompObj = ADCompOU.Create("Computer", "cn=" & CompName)
> ¤ ADCompObj.Put "sAMAccountName", CompName & "$"
> ¤ ADCompObj.Put "UserAccountControl", "4128"
> ¤ ADCompObj.SetInfo
> ¤ If Err.Number <> 0 Then
> ¤ MsgBox "Could Not Create AD Object: " & CompName & "." & vbCrLf & _
> ¤ "Contact Zales Support Team.", vbExclamation
> ¤ Exit Sub
> ¤ End If
> ¤
> ¤ Now I am moving to Windows PE 3.0 (Windows 7 based) becuase of native SATA
> ¤ AHCI & RAID support as well as newer NIC drivers that I have had trouble
> ¤ getting to work on Windows PE 1.2. I have added all the groovy MS packages
> ¤ for Windows PE 3.0 to cover scripting and I have used a 3rd party INF to add
> ¤ ADSI support. Unfortunately when the NameSpace.OpenDSObject method is
> ¤ executed I get a "unknown username or bad password" error. For grins I
> ¤ copied the same code into a VBScript including the code that sets the
> ¤ variables, so I know I didn't change anything like a username or password
> ¤ accidentally. The VBScript executes fine in the same Windows PE 3.0
> ¤ environment. I open my VB6 app and it fails again.
> ¤
> ¤ Does anyone have any ideas?
> ¤
> ¤ I thank you all in advance for any help and for suffering through this
> ¤ extremely long post.
> ¤
> ¤ Regards,
> ¤ Scott Heath
>
> Did you copy the VBScript code back to your VB 6.0 program and try running it again? I'm sure there
> are some slight differences. I don't see where the constants are defined so I will assume that they
> have the correct values.
>
>
> Paul
> ~~~~
> Microsoft MVP (Visual Basic)
> .
>
From: Paul Clement on
On Tue, 9 Feb 2010 12:38:01 -0800, Scott Heath <ScottHeath(a)discussions.microsoft.com> wrote:

� Thanks for the response Paul. The variables are defined in another
� subroutine based upon environment (PROD\QA\DEV), but I confirmed they were
� correct.

� I was able to solve the problem by change the username format. I had been
� using the classic "domain\username", as I had for years. We are actually
� still using Windows Server 2000 DCs. (Bleh!). On a lark I changed it to
� "username(a)domain.com" and it fixed the problem. This makes no sense to me
� because I am using the same activeds.dll for both the VBScript and VB6 code,
� but it will only work one way in VB6 since my change to Windows PE 3.0. I am
� guessing that a registry entry somewhere changed that it forcing VB6 to
� behave certain way, but I made no custom registry entries between PE 1.2 and
� 3.0.

� In any case, I thank you for your response. If you have any suggestions as
� to the cause of this anomoly I'd be interested.

� Thanks,
� Scott


Not sure why the UPN (user principal name) format would work but domain\username would not. You
should be able to use either one.


Paul
~~~~
Microsoft MVP (Visual Basic)
 | 
Pages: 1
Prev: Easy question
Next: Suggection on Image box