Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » .NET General

Post new topic   Reply to topic
Getting the canonicalName from within Visual Basic
View previous topic :: View next topic  
Author Message
Certaeus
Newbie


Joined: 31 Aug 2005
Posts: 2

PostPosted: Aug 31st, 2005 10:31 AM    Post subject: Getting the canonicalName from within Visual Basic Reply with quote

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
View user's profile Send private message
DoobieKeebler
Moderator


Joined: 17 Jun 2005
Posts: 254
Location: 181°15'2.003"W, 93°5'16.956"N

PostPosted: Aug 31st, 2005 02:23 PM    Post subject: Reply with quote

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
View user's profile Send private message
Certaeus
Newbie


Joined: 31 Aug 2005
Posts: 2

PostPosted: Sep 1st, 2005 02:42 AM    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » .NET General All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic