Page 2 of 2 <12
Topic Options
#192878 - 2009-03-13 09:31 PM Re: Subnet / VPN Problem [Re: Glenn Barnas]
aacajo Offline
Fresh Scripter

Registered: 2009-02-13
Posts: 34
Loc: Canada
Excuse me for my dumbness but with that NicInfo function how would you do this:

IF NIC=VPN Adapter
Skip to local adapter
ENDIF

IF DNSSUFFIX = domain.com
look at 3rd octet of IP address
set 3rd octet to $3rdOctet
ELSE
exit
ENDIF


I'm just not sure how to pull info out of the array as I do not have much experience with using arrays at all...I can just google it if it is too troublesome I keep peppering you guys with these dumb questions! Thanks again!

Top
#192880 - 2009-03-13 10:54 PM Re: Subnet / VPN Problem [Re: aacajo]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, he actually gave the ready script for the subnet and vpn part.
_________________________
!

download KiXnet

Top
#192889 - 2009-03-14 12:34 AM Re: Subnet / VPN Problem [Re: Lonkero]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
The example in the header shows exactly how to enumerate the arrays. Since the header also shows which element contains what data, simply modify the example a bit..

Using the example, use the outer $X For/Next loop. Instead of an inner loop, you'd reference a specific element - the one containing the adapter name
If InStr($Array[$X][0], 'VPN')
'This is the VPN adapter!' ?
EndIf

However, since the code explicitly avoids logical adapters and reports ONLY on physical adapters, this would be unnecessary, don'tcha think? \:D

Glenn

PS - ALWAYS try the example code in the UDF headers using a simple little script - it's the best way to learn how to use the UDF and see how the data is returned.
_________________________
Actually I am a Rocket Scientist! \:D

Top
#192916 - 2009-03-16 04:00 PM Re: Subnet / VPN Problem [Re: Glenn Barnas]
aacajo Offline
Fresh Scripter

Registered: 2009-02-13
Posts: 34
Loc: Canada
Ah good advice looking at the header...lol It makes so much more sense now! Duh...

Now I've tested the UDF for the internal network and an external network. The physical adapter returns the following on 8.

Internal: COMPUTERNAME;domain.com;domain.com
External: COMPUTERNAME;;domain.com

I can use the second value to check:

If 2nd value(DNS Suffix) = domain.com

check ip and map printers

Else map network drives and exit.

I'm looking at your UDF and I see the section where you set this value except they all seem to equal $_WorkArray[8] How would I pull the 2nd value out of that? Thanks for tutoring me on my way through this!

Top
#192917 - 2009-03-16 04:38 PM Re: Subnet / VPN Problem [Re: aacajo]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
The header describes the data for element 8 as
 Code:
Domain Info: Hostname;Connection;Primary;Search List **, *** 

This lists the hostname, the Connection-Specific DNS Domain, the Primary DNS Domain, and the domain-name search list. The first $_WorkArray[8]= line sets the hostname. The next reads a reg value and appends to $_WorkArray[8]. There's a third reference farther on that adds two more values to the list.

This value can be complicated - I could have returned an array of arrays, but this often makes things too complicated.. instead, I chose to return a list that consists of values.
You can use $DomainInfo=Split($WorkArray[8], ';') to create an array containing the hostname, connection, primary, and search values. Be aware that the last item - search - can contain multiple domain names, separated by spaces. This would generally not be used to determine domain location or membership. By using this command, you could reference the connection domain as $DomainInfo[1]

The way things should work - if everything is properly configured in the network - is:
Computer name is HOSTNAME.PRIMARY_DOMAIN (elements 0 & 2) - UNLESS "connection" is defined.
If "Connection" is defined (usually due to two or more active NICs, including a VPN connection) the computer name is HOSTNAME.CONNECTION_DOMAIN when communicating through the specific connection. Thus, a computer could have multiple identities in a complex network.
The last field - Search List - is used when the local computer tries to identify non-qualified hostnames.. for example, if you "PING THATHOST", it first appends the primary domain or connection-specific domain if appropriate to the outbound interface.. if there's no reply, it appends each of the domain names in the search list until it gets a reply or gives up.

This illustrates why the data returns different values for internal and external in your example.. the external does not have a connection-specific domain defined, only a primary domain.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#192926 - 2009-03-16 08:04 PM Re: Subnet / VPN Problem [Re: Glenn Barnas]
aacajo Offline
Fresh Scripter

Registered: 2009-02-13
Posts: 34
Loc: Canada
Awesome this should work...so close I can taste it!

Getting a comma return error with $DomainInfo=Split($_WorkArray[8]';')

I added $DomainInfo=Split($_WorkArray[8],';') and I'm still getting the same error. Something I need to look at with syntax? This appears correct to me..

Top
#192936 - 2009-03-17 10:59 AM Re: Subnet / VPN Problem [Re: aacajo]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
what means "comma return error"?
_________________________
!

download KiXnet

Top
#192937 - 2009-03-17 11:55 AM Re: Subnet / VPN Problem [Re: Lonkero]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
You can't split the array that's inside the function! I was pointing out how the function loads the array it returns and how you might reference it..

How are you calling the function? What is the local var name? That's what you need to split. Sorry that wasn't more clear.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#192946 - 2009-03-17 04:57 PM Re: Subnet / VPN Problem [Re: Glenn Barnas]
aacajo Offline
Fresh Scripter

Registered: 2009-02-13
Posts: 34
Loc: Canada
How would I send the output of your function in to an array out side of the function? Like for the return values such as 0-19 in the list would be assigned to $array[0] through $array[19]?
Top
#192947 - 2009-03-17 05:12 PM Re: Subnet / VPN Problem [Re: aacajo]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
The same way you would use any function, built-in or otherwise.

$Result = Function(args)

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
Page 2 of 2 <12


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 874 anonymous users online.
Newest Members
StuTheCoder, M_Moore, BeeEm, min_seow, Audio
17884 Registered Users

Generated in 0.122 seconds in which 0.097 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org