• RSS
  • Twitter
  • FaceBook

Welcome to ISAserver.org

Forums | Register | Login | My Profile | Inbox | RSS RSS icon | My Subscription | My Forums | Address Book | Member List | Search | FAQ | Ticket List | Log Out

How to get ISA Server's MAC Address?

Users viewing this topic: none

Logged in as: Guest
  Printable Version
All Forums >> [ISA Server 2004 Misc.] >> ISA Server 2004 Programming >> How to get ISA Server's MAC Address? Page: [1]
Login
Message << Older Topic   Newer Topic >>
How to get ISA Server's MAC Address? - 24.Nov.2005 4:02:13 AM   
liuyuanxun_1983

 

Posts: 16
Joined: 17.Aug.2005
From: china
Status: offline
I have finished writting a AppFilter and want to sell it. I want to get the ISA Server's MAC Address as it's id. And check whether the AppFilter has registered. But I have a problem with getting ISA Server's MAC Address. Who can tell me how to get it?
Post #: 1
RE: How to get ISA Server's MAC Address? - 24.Nov.2005 4:34:08 AM   
LLigetfa

 

Posts: 2187
Joined: 10.Aug.2004
From: fort frances.on.ca
Status: offline
WMI will do it for you.  Here is a script I have that returns the MAC and more.
strComputer = "."
Set objWMIService = GetObject _
   ("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colAdapters = objWMIService.ExecQuery _
   ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objAdapter in colAdapters
   Wscript.Echo "Host name: " & objAdapter.DNSHostName
   Wscript.Echo "DNS domain: " & objAdapter.DNSDomain
   Wscript.Echo "DNS suffix search list: " & objAdapter.DNSDomainSuffixSearchOrder
   Wscript.Echo "Description: " & objAdapter.Description
   Wscript.Echo "Physical address: " & objAdapter.MACAddress
   Wscript.Echo "DHCP enabled: " & objAdapter.DHCPEnabled
   If Not IsNull(objAdapter.IPAddress) Then
       For i = LBound(objAdapter.IPAddress) To UBound(objAdapter.IPAddress)
           Wscript.Echo "IP address: " & objAdapter.IPAddress(i)
       Next
   End If
   If Not IsNull(objAdapter.IPSubnet) Then
       For i = LBound(objAdapter.IPSubnet) To UBound(objAdapter.IPSubnet)
           Wscript.Echo "Subnet: " & objAdapter.IPSubnet(i)
       Next
   End If
   If Not IsNull(objAdapter.DefaultIPGateway) Then
       For i = LBound(objAdapter.DefaultIPGateway) To UBound(objAdapter.DefaultIPGateway)
           Wscript.Echo "Default gateway: " & objAdapter.DefaultIPGateway(i)
       Next
   End If
   Wscript.Echo "DHCP server: " & objAdapter.DHCPServer
   If Not IsNull(objAdapter.DNSServerSearchOrder) Then
       For i = LBound(objAdapter.DNSServerSearchOrder) To UBound(objAdapter.DNSServerSearchOrder)
           Wscript.Echo "DNS server: " & objAdapter.DNSServerSearchOrder(i)
       Next
   End If
   Wscript.Echo "Primary WINS server: " & objAdapter.WINSPrimaryServer
   Wscript.Echo "Secondary WINS server: " & objAdapter.WINSSecondaryServer
   Wscript.Echo "Lease obtained: " & objAdapter.DHCPLeaseObtained
   Wscript.Echo "Lease expires: " & objAdapter.DHCPLeaseExpires
Next


< Message edited by LLigetfa -- 24.Nov.2005 4:46:48 AM >


_____________________________

The School of Hard Knocks is a mean teacher. She gives the exam before the lesson.

(in reply to liuyuanxun_1983)
Post #: 2
RE: How to get ISA Server's MAC Address? - 26.Nov.2005 3:23:02 AM   
liuyuanxun_1983

 

Posts: 16
Joined: 17.Aug.2005
From: china
Status: offline
I have solved this problem illumined by an article from www.codeguru.com. My code is as follow:

#include "Iphlpapi.h"
DWORD sizeReq = 0 ;
PMIB_IFTABLE pInfo = NULL;
// Get size information
::GetIfTable(NULL, &sizeReq, FALSE) ; // Allocate required memory
pInfo = (PMIB_IFTABLE) new BYTE [sizeReq] ;
memset (pInfo, 0, sizeReq) ; DWORD sizeToUse = sizeReq ; // Retrieve network interface information
bool result = ( ::GetIfTable( (PMIB_IFTABLE)pInfo,&sizeToUse, FALSE) == NO_ERROR );
if( !result )
{
 delete (PMIB_IFTABLE)pInfo;
 pInfo = NULL;
} char macStr[100] = {0};
// Print all interface information
for( unsigned int index = 0; index <
 ((PMIB_IFTABLE)pInfo)->dwNumEntries; index ++ )
{
 // Get interface description
 MIB_IFROW& details = ((PMIB_IFTABLE)pInfo)->table[index];  // Is this an Ethernet interface?
 if( (details.dwPhysAddrLen == 6)
  && (details.dwType == MIB_IF_TYPE_ETHERNET) )
 {
  // Ethernet MAC address
  printf("     Ethernet: ");
 }
 else    // Other interface
 {
  //printf("     Others: ");
 }  // Format physical address
 memset(macStr,0,sizeof(macStr));  DWORD j;
 for ( j = 0 ; j < details.dwPhysAddrLen ; ++j)
 {
  sprintf( &macStr[j*3], "%02X-", details.bPhysAddr[j] );
 }
 if ( 0 != j )
 {
  macStr[j*3-1] = '\0';    //we can get mac address here  } .
}

(in reply to liuyuanxun_1983)
Post #: 3

Page:   [1] << Older Topic    Newer Topic >>
All Forums >> [ISA Server 2004 Misc.] >> ISA Server 2004 Programming >> How to get ISA Server's MAC Address? Page: [1]
Jump to:

New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts