Array(Value & "|" & Value2) from VB6 to VB.Net 2008

M

Mark B

Hi experts,

I'm converting a homebrew AD management progam I wrote, from VB6 to VB 2008.

I've got some code that sticks values in to Active Directory like this:-

objOU.PutEx ADS_PROPERTY_APPEND, "wbempath, Array(Product & "|" and Key)

Basically, a convenient place for me to store and manage CD installation
keys.

In VB6, the 'Array' bit works fine.

VB 2008 spits it out. "'Array' is a type and cannot be used as an
expression."

What is the equivalent syntax in VB 2008?

Thanks,

Mark B
 
H

Herfried K. Wagner [MVP]

Mark B said:
I'm converting a homebrew AD management progam I wrote, from VB6 to VB
2008.

I've got some code that sticks values in to Active Directory like this:-

objOU.PutEx ADS_PROPERTY_APPEND, "wbempath, Array(Product & "|" and Key)

There's something wrong with the code above, it won't even compile in VB6.
 
M

Mark B

Sorry, you've got to have a reference to Active DS Type library.

....

Set objou = GetObject("LDAP://CN=InstallKeys," & MyDomain)

objOU.PutEX ADS_PROPERTY_APPEND, "wbempath", Array(Product & "|" & Key)

ObjOu.SetInfo

Set objOU = Nothing

....

The "MyDomain" bit is the FQDN of my domain. (DC=MySite, DC=GOV, DC=AU),
etc.

ADS_PROPERTY_APPEND = 3.

"InstallKeys" is a container node in the root of my Active Directory (a
contact).

Product = "Windows XP SP2 Integrated" or some other string that the key is
for.

The pipe -"|" is used to delimit the product and the key, when reading back
the info later.

The key is the installation key or code.

Notice also I had a missing " at the end of "wbempath".

Apologies.

Mark
 
B

Bill McCarthy

Hi Mark,

Array(Product & "|" & Key) is a single element array with a single string
value. I'd try :

objOU.PutEX ADS_PROPERTY_APPEND, "wbempath", Product & "|" & Key

Or:

objOU.PutEX ADS_PROPERTY_APPEND, "wbempath", New String() { Product & "|" &
Key}

Or:

objOU.PutEX ADS_PROPERTY_APPEND, "wbempath", New Object() { Product & "|" &
Key}







Mark B said:
Sorry, you've got to have a reference to Active DS Type library.

...

Set objou = GetObject("LDAP://CN=InstallKeys," & MyDomain)

objOU.PutEX ADS_PROPERTY_APPEND, "wbempath", Array(Product & "|" & Key)

ObjOu.SetInfo

Set objOU = Nothing

...

The "MyDomain" bit is the FQDN of my domain. (DC=MySite, DC=GOV, DC=AU),
etc.

ADS_PROPERTY_APPEND = 3.

"InstallKeys" is a container node in the root of my Active Directory (a
contact).

Product = "Windows XP SP2 Integrated" or some other string that the key is
for.

The pipe -"|" is used to delimit the product and the key, when reading
back the info later.

The key is the installation key or code.

Notice also I had a missing " at the end of "wbempath".

Apologies.

Mark
 
M

Mark B

You guys (and Bill, especially) are just freakin legends!

Thanks Group!

(This one did it...)

objOU.PutEX ADS_PROPERTY_APPEND, "wbempath", New Object() { Product & "|" &
Key}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top