Page 1 of 2 12>
Topic Options
#154781 - 2006-01-09 08:04 AM RFC - GetIPOptions()
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
I'm writing this to compliment SetIPOptions() and to address a request from this thread.

It should be able to accept any valid property from Win32_NetworkAdapterConfiguration class, including a few I created (ie StaticIP). Below are a few of the ones I targeted and tested. The function should always return a string.

I could really use someone to try out:
1. A PC with multiple NICs
2. Test it on a remote PC

Suggestions, Comments?


GetIPOptions()
EnumNetworkConnections()

Top
#154782 - 2006-01-09 09:33 PM Re: RFC - GetIPOptions()
dataspike Offline
Getting the hang of it

Registered: 2005-03-09
Posts: 89
Loc: San Diego, CA
Dude... you have absolutely no idea how much you rock. That's awesome!
Top
#154783 - 2006-01-09 10:24 PM Re: RFC - GetIPOptions()
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Quote:


....
I could really use someone to try out:
1. A PC with multiple NICs
2. Test it on a remote PC
....





Allen,

How far did you get with this already?
Got some servers at work with two and three nic's acting as individual nic's and at least one server with two nic’s teamed.
If still wanted I can let it rip at these servers and at a remote comp when I'm back @work on Wednesday.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#154784 - 2006-01-09 10:27 PM Re: RFC - GetIPOptions()
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Mart, I would really appreciate it if you could try it out. I don't have the resources, at my finger tips, like I used to.
Top
#154785 - 2006-01-09 10:36 PM Re: RFC - GetIPOptions()
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Ok did some messing around at my home comp.

It has 2 "normal" NIC's, one wireless NIC, a Bluetooth thingy and a 1394 connection.
When the BT connection is enabled it gives all 0's as the IP, SN, Def GW, etc....
When the BT connection is disabled it takes the IP's from the first connected NIC (wireless in my case). Is it possible to add the connection name to the output (Local Area Connection, Local Area Connection 2, etc…)? At the first line maybe?

Here is the output.

Quote:


Static Address: False
DHCP Enabled: True
IPaddress/SM: 192.168.2.100,255.255.255.0
IPaddress0/SM: 192.168.2.100,255.255.255.0
IPaddress1/SM:
IPaddress2/SM:
IPaddress3/SM:
DefaultGW: 192.168.2.1
DNS Servers: 192.168.1.1,62.58.50.6
WINS Servers:
DNSSuffix:
DNS Search Order:
DHCP Server: 192.168.2.1
DHCP Lease Obtained: 20060109201156.000000+060
DHCP Lease Expires: 20060119201156.000000+060





Will check against a remote comp and the teamed stuff @work on Wednesday.

[edit]
D#mn. Should pay more attention to what I'm doing. Just logged off our terminal server and clicked reboot in stead off logoff More proof that men can't do two things at the same time. Working from home and kixing.
[/edit]


Edited by Mart (2006-01-09 10:38 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#154786 - 2006-01-10 12:05 AM Re: RFC - GetIPOptions()
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Just trying to give folks at work a fresh start
Top
#154787 - 2006-01-10 12:11 AM Re: RFC - GetIPOptions()
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Worked fine for me both locally and remotely Allen.

Did not test dual nic though.

Top
#154788 - 2006-01-10 12:27 AM Re: RFC - GetIPOptions()
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Maybe add the MAC in your example too here or when you create and publish UDF.

? " Mac Address: " + getipoptions("Macaddress")
 

Top
#154789 - 2006-01-10 01:32 AM Re: RFC - GetIPOptions()
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Thanks for testing Doc. Added macaddress to the samples above... but its also listed in the Win32_NetworkAdapterConfiguration properties link.

Thinking about changing IPAddress so that it returns all the IPs associated with the NIC (as WMI does it), and leaving the IPAddress0, IPAddress1, etc, to return the IPAddress and Subnet Mask.

Top
#154790 - 2006-01-10 09:05 AM Re: RFC - GetIPOptions()
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Mart, I've been trying to think what would cause you to get no results... and I think I now know... because of the loop its displaying what ever the last adapter is, which is likely the BT or 1394 adapter...

I guess I need to think this out a little better.

Top
#154791 - 2006-01-11 04:50 PM Re: RFC - GetIPOptions()
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
As promised.
Did a test against a remote pc with two teamed Intel 10/100/1000 nics.
MAC of the team is shown as expected.

Quote:


Static Address: True
DHCP Enabled: False
IPaddress/SM: 192.168.1.4,255.255.255.0
IPaddress0/SM: 192.168.1.4,255.255.255.0
IPaddress1/SM:
IPaddress2/SM:
IPaddress3/SM:
DefaultGW: 192.168.1.8
DNS Servers: 192.168.1.1
WINS Servers: 127.0.0.0,127.0.0.0
DNSSuffix:
DNS Search Order:
DHCP Server: 192.168.1.1
DHCP Lease Obtained:
DHCP Lease Expires:
Mac Address: 00:02:B3:BE:2F:DF





Just specifying a value for $remotepc gives an error about undefined variable cause explicit is on and $remotepc is not dimmed I guess.


Edited by Mart (2006-01-11 04:52 PM)

Top
#154792 - 2006-01-11 05:28 PM Re: RFC - GetIPOptions()
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
No $remotepc is a parameter and should not be dimmed Mart.

Perhaps whatever you called your var when you called the UDF?

Top
#154793 - 2006-01-12 09:30 AM Re: RFC - GetIPOptions()
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
DOH My bad.
Maybe I did a little typo or so, will see.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#154794 - 2006-01-27 04:07 PM Re: RFC - GetIPOptions()
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Okay... I might actually have some time this weekend to mess with this.

Mart would you mind running the following code on the box where you had multiple adapters, and post the results?

Code:
 
Break On
$strComputer = "."
$objWMIService = GetObject("winmgmts:\\" + $strComputer + "\root\cimv2")
$colItems = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration",,48)
For each $objItem in $colItems
"ArpAlwaysSourceRoute: " + $objItem.ArpAlwaysSourceRoute ?
"ArpUseEtherSNAP: " + $objItem.ArpUseEtherSNAP ?
"Caption: " + $objItem.Caption ?
"DatabasePath: " + $objItem.DatabasePath ?
"DeadGWDetectEnabled: " + $objItem.DeadGWDetectEnabled ?
For each $Item in $objItem.DefaultIPGateway
"*DefaultIPGateway: " + $Item ?
Next
"DefaultTOS: " + $objItem.DefaultTOS ?
"DefaultTTL: " + $objItem.DefaultTTL ?
"Description: " + $objItem.Description ?
"DHCPEnabled: " + $objItem.DHCPEnabled ?
"DHCPLeaseExpires: " + $objItem.DHCPLeaseExpires ?
"DHCPLeaseObtained: " + $objItem.DHCPLeaseObtained ?
"DHCPServer: " + $objItem.DHCPServer ?
"DNSDomain: " + $objItem.DNSDomain ?
For each $Item in $objItem.DNSDomainSuffixSearchOrder
"*DNSDomainSuffixSearchOrder: " + $Item ?
Next
"DNSEnabledForWINSResolution: " + $objItem.DNSEnabledForWINSResolution ?
"DNSHostName: " + $objItem.DNSHostName ?
For each $Item in $objItem.DNSServerSearchOrder
"*DNSServerSearchOrder: " + $Item ?
Next
"DomainDNSRegistrationEnabled: " + $objItem.DomainDNSRegistrationEnabled ?
"ForwardBufferMemory: " + $objItem.ForwardBufferMemory ?
"FullDNSRegistrationEnabled: " + $objItem.FullDNSRegistrationEnabled ?
For each $Item in $objItem.GatewayCostMetric
"*GatewayCostMetric: " + $Item ?
Next
"IGMPLevel: " + $objItem.IGMPLevel ?
"Index: " + $objItem.Index ?
For each $Item in $objItem.IPAddress
"*IPAddress: " + $Item ?
Next
"IPConnectionMetric: " + $objItem.IPConnectionMetric ?
"IPEnabled: " + $objItem.IPEnabled ?
"IPFilterSecurityEnabled: " + $objItem.IPFilterSecurityEnabled ?
"IPPortSecurityEnabled: " + $objItem.IPPortSecurityEnabled ?
For each $Item in $objItem.IPSecPermitIPProtocols
"*IPSecPermitIPProtocols: " + $Item ?
Next
For each $Item in $objItem.IPSecPermitTCPPorts
"*IPSecPermitTCPPorts: " + $Item ?
Next
For each $Item in $objItem.IPSecPermitUDPPorts
"*IPSecPermitUDPPorts: " + $Item ?
Next
For each $Item in $objItem.IPSubnet
"*IPSubnet: " + $Item ?
Next
"IPUseZeroBroadcast: " + $objItem.IPUseZeroBroadcast ?
"IPXAddress: " + $objItem.IPXAddress ?
"IPXEnabled: " + $objItem.IPXEnabled ?
"IPXFrameType: " + $objItem.IPXFrameType ?
"IPXMediaType: " + $objItem.IPXMediaType ?
"IPXNetworkNumber: " + $objItem.IPXNetworkNumber ?
"IPXVirtualNetNumber: " + $objItem.IPXVirtualNetNumber ?
"KeepAliveInterval: " + $objItem.KeepAliveInterval ?
"KeepAliveTime: " + $objItem.KeepAliveTime ?
"MACAddress: " + $objItem.MACAddress ?
"MTU: " + $objItem.MTU ?
"NumForwardPackets: " + $objItem.NumForwardPackets ?
"PMTUBHDetectEnabled: " + $objItem.PMTUBHDetectEnabled ?
"PMTUDiscoveryEnabled: " + $objItem.PMTUDiscoveryEnabled ?
"ServiceName: " + $objItem.ServiceName ?
"SettingID: " + $objItem.SettingID ?
"TcpipNetbiosOptions: " + $objItem.TcpipNetbiosOptions ?
"TcpMaxConnectRetransmissions: " + $objItem.TcpMaxConnectRetransmissions ?
"TcpMaxDataRetransmissions: " + $objItem.TcpMaxDataRetransmissions ?
"TcpNumConnections: " + $objItem.TcpNumConnections ?
"TcpUseRFC1122UrgentPointer: " + $objItem.TcpUseRFC1122UrgentPointer ?
"TcpWindowSize: " + $objItem.TcpWindowSize ?
"WINSEnableLMHostsLookup: " + $objItem.WINSEnableLMHostsLookup ?
"WINSHostLookupFile: " + $objItem.WINSHostLookupFile ?
"WINSPrimaryServer: " + $objItem.WINSPrimaryServer ?
"WINSScopeID: " + $objItem.WINSScopeID ?
"WINSSecondaryServer: " + $objItem.WINSSecondaryServer ?
?
Next


Top
#154795 - 2006-01-27 04:24 PM Re: RFC - GetIPOptions()
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
You mean the system with wifi, copper and Bluetooth connections?
Will do when I'm back home tomorrow or on Sunday.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#154796 - 2006-01-27 08:35 PM Re: RFC - GetIPOptions()
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Yes...that's the one.
Top
#154797 - 2006-01-29 01:20 PM Re: RFC - GetIPOptions()
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Here we go.
All connections enabled but not all connected.
You will see the word stuurprogramma in there, that's Dutch for driver.

- 1 WiFi (connected to my accesspoint)
- 2 Copper (enabled but not connected)
- 1 1394 (enabled but not connected)
- 1 Bleutooth (connected to my cell phone)
- 1 Bleutooth modem (part of the bleutooth phone connection, enaled but not connected)

Code:

IPPortSecurityEnabled:
IPUseZeroBroadcast:
IPXAddress:
IPXEnabled: 0
IPXFrameType:
IPXMediaType:
IPXNetworkNumber:
IPXVirtualNetNumber:
KeepAliveInterval:
KeepAliveTime:
MACAddress: 00:0C:F6:14:68:99
MTU:
NumForwardPackets:
PMTUBHDetectEnabled:
PMTUDiscoveryEnabled:
ServiceName:
SettingID: {67F8C3BC-6B12-4914-9590-C97B1E1E83A8}
TcpipNetbiosOptions:
TcpMaxConnectRetransmissions:
TcpMaxDataRetransmissions:
TcpNumConnections:
TcpUseRFC1122UrgentPointer:
TcpWindowSize:
WINSEnableLMHostsLookup:
WINSHostLookupFile:
WINSPrimaryServer:
WINSScopeID:
WINSSecondaryServer:
;
ArpAlwaysSourceRoute:
ArpUseEtherSNAP:
Caption: [00000015] Bluetooth Device (Personal Area Network)
DatabasePath:
DeadGWDetectEnabled:
DefaultTOS:
DefaultTTL:
Description: Bluetooth Device (Personal Area Network)
DHCPEnabled: -1
DHCPLeaseExpires:
DHCPLeaseObtained:
DHCPServer:
DNSDomain:
DNSEnabledForWINSResolution:
DNSHostName:
DomainDNSRegistrationEnabled:
ForwardBufferMemory:
FullDNSRegistrationEnabled:
IGMPLevel:
Index: 15
IPConnectionMetric:
IPEnabled: 0
IPFilterSecurityEnabled:
IPPortSecurityEnabled:
IPUseZeroBroadcast:
IPXAddress:
IPXEnabled: 0
IPXFrameType:
IPXMediaType:
IPXNetworkNumber:
IPXVirtualNetNumber:
KeepAliveInterval:
KeepAliveTime:
MACAddress:
MTU:
NumForwardPackets:
PMTUBHDetectEnabled:
PMTUDiscoveryEnabled:
ServiceName: BthPan
SettingID: {CFF68E80-0891-4044-BBF0-78F3857D7B6F}
TcpipNetbiosOptions:
TcpMaxConnectRetransmissions:
TcpMaxDataRetransmissions:
TcpNumConnections:
TcpUseRFC1122UrgentPointer:
TcpWindowSize:
WINSEnableLMHostsLookup:
WINSHostLookupFile:
WINSPrimaryServer:
WINSScopeID:
WINSSecondaryServer:
;
ArpAlwaysSourceRoute:
ArpUseEtherSNAP:
Caption: [00000016] Bluetooth stuurprogramma LAN Access Server
DatabasePath: %SystemRoot%\System32\drivers\etc
DeadGWDetectEnabled:
DefaultTOS:
DefaultTTL:
portription: Bluetooth stuurprogramma LAN Access Server - Packet Scheduler Miniport
DHCPEnabled: -1
DHCPLeaseExpires:
DHCPLeaseObtained:
DHCPServer:
DNSDomain:
DNSEnabledForWINSResolution: 0
DNSHostName: challenger
DomainDNSRegistrationEnabled: 0
ForwardBufferMemory:
FullDNSRegistrationEnabled: -1
IGMPLevel:
Index: 16
*IPAddress: 0.0.0.0
IPConnectionMetric: 1
IPEnabled: -1
IPFilterSecurityEnabled: 0
IPPortSecurityEnabled:
*IPSecPermitIPProtocols: 0
*IPSecPermitTCPPorts: 0
*IPSecPermitUDPPorts: 0
*IPSubnet:
IPUseZeroBroadcast:
IPXAddress:
IPXEnabled: 0
IPXFrameType:
IPXMediaType:
IPXNetworkNumber:
IPXVirtualNetNumber:
KeepAliveInterval:
KeepAliveTime:
MACAddress: 00:10:60:AF:C0:8F
MTU:
NumForwardPackets:
PMTUBHDetectEnabled:
PMTUDiscoveryEnabled:
ServiceName: BTWDNDIS
SettingID: {7E9E8D15-9627-403B-8514-4D9652CF6EE5}
TcpipNetbiosOptions: 0
TcpMaxConnectRetransmissions:
TcpMaxDataRetransmissions:
TcpNumConnections:
TcpUseRFC1122UrgentPointer:
TcpWindowSize:
WINSEnableLMHostsLookup: -1
WINSHostLookupFile:
WINSPrimaryServer:
WINSScopeID:
WINSSecondaryServer:
;
ArpAlwaysSourceRoute:
ArpUseEtherSNAP:
Caption: [00000017] Packet Scheduler Miniport
DatabasePath:
DeadGWDetectEnabled:
DefaultTOS:
DefaultTTL:
Description: Packet Scheduler Miniport
DHCPEnabled: 0
DHCPLeaseExpires:
DHCPLeaseObtained:
DHCPServer:
DNSDomain:
DNSEnabledForWINSResolution:
DNSHostName:
DomainDNSRegistrationEnabled:
ForwardBufferMemory:
FullDNSRegistrationEnabled:
IGMPLevel:
Index: 17
IPConnectionMetric:
IPEnabled: 0
IPFilterSecurityEnabled:
IPPortSecurityEnabled:
IPUseZeroBroadcast:
IPXAddress:
IPXEnabled: 0
IPXFrameType:
IPXMediaType:
IPXNetworkNumber:
IPXVirtualNetNumber:
KeepAliveInterval:
KeepAliveTime:
MACAddress: 00:10:60:AF:C0:8F
MTU:
NumForwardPackets:
PMTUBHDetectEnabled:
PMTUDiscoveryEnabled:
ServiceName:
SettingID: {4D806036-BD07-4DE3-9530-8364792A8248}
TcpipNetbiosOptions:
TcpMaxConnectRetransmissions:
TcpMaxDataRetransmissions:
TcpNumConnections:
TcpUseRFC1122UrgentPointer:
TcpWindowSize:
WINSEnableLMHostsLookup:
WINSHostLookupFile:
WINSPrimaryServer:
WINSScopeID:
WINSSecondaryServer:
;
ArpAlwaysSourceRoute:
ArpUseEtherSNAP:
Caption: [00000018] 1394 Net Adapter
DatabasePath:
DeadGWDetectEnabled:
DefaultTOS:
DefaultTTL:
Description: 1394 Net Adapter
DHCPEnabled: -1
DHCPLeaseExpires:
DHCPLeaseObtained:
DHCPServer:
DNSDomain:
DNSEnabledForWINSResolution:
DNSHostName:
DomainDNSRegistrationEnabled:
ForwardBufferMemory:
FullDNSRegistrationEnabled:
IGMPLevel:
Index: 18
IPConnectionMetric:
IPEnabled: 0
IPFilterSecurityEnabled:
IPPortSecurityEnabled:
IPUseZeroBroadcast:
IPXAddress:
IPXEnabled: 0
IPXFrameType:
IPXMediaType:
IPXNetworkNumber:
IPXVirtualNetNumber:
KeepAliveInterval:
KeepAliveTime:
MACAddress: 12:6C:11:62:E3:29
MTU:
NumForwardPackets:
PMTUBHDetectEnabled:
PMTUDiscoveryEnabled:
ServiceName: NIC1394
SettingID: {80677346-6F0E-4A2F-B809-84847B376D66}
TcpipNetbiosOptions:
TcpMaxConnectRetransmissions:
TcpMaxDataRetransmissions:
TcpNumConnections:
TcpUseRFC1122UrgentPointer:
TcpWindowSize:
WINSEnableLMHostsLookup:
WINSHostLookupFile:
WINSPrimaryServer:
WINSScopeID:
WINSSecondaryServer:
;
ArpAlwaysSourceRoute:
ArpUseEtherSNAP:
Caption: [00000019] Microsoft TV/Video Connection
DatabasePath: %SystemRoot%\System32\drivers\etc
DeadGWDetectEnabled:
DefaultTOS:
DefaultTTL:
Description: Intel(R) PRO/100 VM Network Connection - Packet Scheduler Miniport
DHCPEnabled: -1
DHCPLeaseExpires:
DHCPLeaseObtained:
DHCPServer:
DNSDomain:
DNSEnabledForWINSResolution: 0
DNSHostName: challenger
DomainDNSRegistrationEnabled: 0
ForwardBufferMemory:
FullDNSRegistrationEnabled: -1
IGMPLevel:
Index: 19
*IPAddress: 0.0.0.0
IPConnectionMetric: 1
IPEnabled: -1
IPFilterSecurityEnabled: 0
IPPortSecurityEnabled:
*IPSecPermitIPProtocols: 0
*IPSecPermitTCPPorts: 0
*IPSecPermitUDPPorts: 0
*IPSubnet:
IPUseZeroBroadcast:
IPXAddress:
IPXEnabled: 0
IPXFrameType:
IPXMediaType:
IPXNetworkNumber:
IPXVirtualNetNumber:
KeepAliveInterval:
KeepAliveTime:
MACAddress: 00:0B:CD:04:28:D1
MTU:
NumForwardPackets:
PMTUBHDetectEnabled:
PMTUDiscoveryEnabled:
ServiceName: NdisIP
SettingID: {E8645DEA-9366-4AF2-B161-82B3264C54A8}
TcpipNetbiosOptions: 0
TcpMaxConnectRetransmissions:
TcpMaxDataRetransmissions:
TcpNumConnections:
TcpUseRFC1122UrgentPointer:
TcpWindowSize:
WINSEnableLMHostsLookup: -1
WINSHostLookupFile:
WINSPrimaryServer:
WINSScopeID:
WINSSecondaryServer:

_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#154798 - 2006-03-08 11:56 PM Re: RFC - GetIPOptions()
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Ok, I worked with this in regards to this post http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=158386&an=0&page=0#158386 and used this code

Code:

Break On
$=setoption("Wrapateol","on")
$=setoption("Explicit","on")
$=setoption("NoVarsinstrings","on")
$=setoption("NoMacrosinstrings","on")

dim $Server[],$
Open (1,"C:\DNS_Log.TXT",5)

$Server = ;had 41 servers listed here

For Each $ in $Server

;? " Static Address: " + getipoptions("StaticIP")
;? " DHCP Enabled: " + getipoptions("DHCPEnabled")
;? " IPaddress/SM: " + getipoptions("IPAddress")
;? " IPaddress0/SM: " + getipoptions("IPAddress0")
;? " IPaddress1/SM: " + getipoptions("IPAddress1")
;? " IPaddress2/SM: " + getipoptions("IPAddress2")
;? " IPaddress3/SM: " + getipoptions("IPAddress3")
;? " DefaultGW: " + getipoptions("DefaultGW")
Writeline(1," Server: "+$+@CRLF)
Writeline(1," DNS Servers: " + getipoptions("DNSServers",$)+@CRLF)
;? " WINS Servers: " + getipoptions("WINSServers")
;? " DNSSuffix: " + getipoptions("DNSDomain")
;? " DNS Search Order: " + getipoptions("DNSDomainSuffixSearchOrder")
;? " DHCP Server: " + getipoptions("DHCPServer")
;? "DHCP Lease Obtained: " + getipoptions("DHCPLeaseObtained")
;? " DHCP Lease Expires: " + getipoptions("DHCPLeaseExpires")
;? " Mac Address: " + getipoptions("Macaddress")

Next

Close(1)









function GetIPOptions($Setting,optional $remotepc, optional $macaddress)
dim $objWMIService, $colitems, $objnetadapter,$targetadapter,$,$allnics,$counter,$Mask,$SN, $IP, $IPAddress,$toggle
if $remotepc=""
$remotepc="."
endif
if $macaddress=""
$allnics=1
endif
$objWMIService = GetObject("winmgmts:\\" + $remotepc + "\root\cimv2")
if @error
exit @error
endif
$colItems = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=-1")
For Each $objNetAdapter In $colItems
if $macaddress=$objNetAdapter.macaddress or $allnics
select
case instr($setting,"IPAddress")>0
if right($setting,1)="s" or val(right($setting,1))>3 or len($setting)>10
$targetadapter=0
else
$targetadapter=right($setting,1)
endif
$counter=0
for each $IP in $objNetAdapter.IPAddress
if "" + $counter=$targetadapter
$IPAddress=$IP
endif
$counter=$counter+1
next
$counter=0
for each $SN in $objNetAdapter.IPSubnet
if "" + $counter=$targetadapter
$Mask=$SN
endif
$counter=$counter+1
next
$GetIPOptions=$IPAddress
if $mask
$GetIPOptions=$GetIPOptions + "," + $Mask
endif
case $setting="WINSServers"
$GetIPOptions=$objNetAdapter.WINSPrimaryServer
if $objNetAdapter.WINSSecondaryServer<>""
$GetIPOptions=$GetIPOptions + "," + $objNetAdapter.WINSSecondaryServer
endif
case 1
select
case $setting="DefaultGW" or $setting="DefaultGateway" or $setting="Gateway"
$setting="DefaultIPGateway"
case $setting="DNSServers"
$setting="DNSServerSearchOrder"
case $setting="StaticIP" or $setting="Static"
$setting="DHCPEnabled"
$toggle=1
endselect
$=execute("$" + "GetIPOptions=" + "$" + "objNetAdapter." + $setting)
select
case vartype($GetIPOptions)>=8192 ;array
$GetIPOptions=join($GetIPOptions,",")
case vartype($GetIPOptions)=11 ;boolean
if $GetIPOptions=0 - $toggle
$GetIPOptions="False"
else
$GetIPOptions="True"
endif
endselect
endselect
endif
Next
endfunction



Everything worked just fine, however it only reported the last active NIC for systems that had multiple active NIC's
_________________________
Today is the tomorrow you worried about yesterday.

Top
#154799 - 2006-03-09 03:57 AM Re: RFC - GetIPOptions()
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
That's by design

The UDF is coded to return the information of the last network interface, if you need to support multiple interfaces, then the UDF needs to be modified to return an array or you need to specify the MAC address of the particular interface you're interested in.
_________________________
There are two types of vessels, submarines and targets.

Top
#154800 - 2006-03-09 04:13 AM Re: RFC - GetIPOptions()
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Yeah guys...we already figured that out... I just haven't had time to mess with this. Sorry... maybe this weekend.
Top
Page 1 of 2 12>


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

Who's Online
0 registered and 628 anonymous users online.
Newest Members
Raoul, Timothy, Jojo67, MaikSimon, kvn317
17875 Registered Users

Generated in 0.074 seconds in which 0.027 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