| View previous topic :: View next topic |
| Author |
Message |
Certaeus Newbie
Joined: 31 Aug 2005 Posts: 2
|
Posted: Aug 31st, 2005 10:31 AM Post subject: Getting the canonicalName from within Visual Basic |
|
|
Hi All,
I hope you can help.
I have put together a script using VBScript that pulls the canonicalName of the domain i am logged on to.
| Code: | set objRoot = GetObject("LDAP://rootDSE")
set objDomain = GetObject("LDAP://" & objRoot.Get("defaultNamingContext"))
objDomain.GetInfoEx Array("canonicalName"), 0
parmsCanonicalName = Split(objDomain.canonicalName, "/")
wscript.echo "The Domain Name is : " & parmsCanonicalName(0) |
but when i come to put this code into a Visual Basic project it craps out saying that i can not use Array as it is a Type.
Any help is appreciated.
Thanks
Certaeus
Last edited by Certaeus on Sep 1st, 2005 02:30 AM; edited 2 times in total |
|
| Back to top |
|
DoobieKeebler Moderator

Joined: 17 Jun 2005 Posts: 254 Location: 181°15'2.003"W, 93°5'16.956"N
|
Posted: Aug 31st, 2005 02:23 PM Post subject: |
|
|
I think I ran into the same problem a few hours ago. Instead of saying:
Dim parmsCanonicalName() As String
(or even without the "As String" part) just say:
Dim parmsCanonicalName
That worked for me. _________________ Always take into account what a user would never ever in a million years do, because someone will.
"In theory, there's no difference between theory and practice. In practice, there is." -- Yogi Berra |
|
| Back to top |
|
Certaeus Newbie
Joined: 31 Aug 2005 Posts: 2
|
Posted: Sep 1st, 2005 02:42 AM Post subject: |
|
|
I'm afraid that doesn't solve the problem,
the code within Visual Basic looks like this
| Code: |
Dim parmsCanonicalName
objRoot = GetObject("LDAP://rootDSE")
objDomain = GetObject("LDAP://" & objRoot.Get("defaultNamingContext"))
objDomain.GetInfoEx(Array("canonicalName"), 0)
parmsCanonicalName = Split(objDomain.canonicalName, "/")
Console.WriteLine("The Domain is: " & parmsCanonicalName(0)) |
which is called by pressing a button.
But the code analyzer say this | Quote: | 'Array' is a type and cannot be used as an expression.
|
what i don't understand is, why the script works fine within a VBScript environment but does not work when put into a Visual Basic .NET project.
Any ideas?
cheers
Certaeus |
|
| Back to top |
|
|