Sign in to follow this  
Followers 0
realkiller

ldap mac

7 posts in this topic




realkiller,

As far as I know this is not possible directly.

Becuse LDAP accesses the AD properties in a domain. And a MAC address is not stored there.

You can write a script to list computers in an OU and than Query the MAC address through WMI.

So indirectly it would be possible though.

Regards

ptrex

Share this post


Link to post
Share on other sites

i think i found a VB script can anyone convert it 2 autoit

Set Shell = Wscript.CreateObject("WScript.Shell")
Set File = CreateObject("Scripting.FileSystemObject")

On Error Resume Next

set Dom = getobject("WinNT://YOURDOMAIN")
Dom.Filter = array("computer")
avail = false

for each item in Dom
ping item.Name,avail
if avail = true then maclist item.Name
next
wscript.echo "MAC address capture complete..."
wscript.quit

'---
'appends PC name and MAC address to macaddr.txt
Function macList(RemotePC)
Set IPConfigSet = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & RemotePC & "\root\cimv2" ).ExecQuery ("SELECT MACAddress FROM Win32_NetworkAdapterConfiguration " & "WHERE IPEnabled=true" )
For Each IPConfig In IPConfigSet
custom = RemotePC & vbTab & IPConfig.MACAddress & vbNewLine
Next

createTempfile custom

fileAppend File.OpenTextFile ("c:\temp.txt"), File.OpenTextFile ("c:\macaddr.txt", 8)
File.DeleteFile "c:\temp.txt", true
End Function


'---
'This function appends one file to another
Function fileAppend(source,destination)
Do While source.AtEndOfline <> true
destination.WriteLine(source.readline)
Loop

source.close
destination.close
End Function


'---
'creates a txt file called temp.txt and write's data from dat to it
Function createTempfile(dat)
Set temp = File.CreateTextFile("c:\temp.txt")
temp.WriteLine dat
temp.Close
End Function


'---
'pings a client

Function ping (RemotePC,avail)
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonat e}").ExecQuery("select * from Win32_PingStatus where address = '" & RemotePC & "'")
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then
avail = false
Else
avail = true
End If
Next
End Function

Share this post


Link to post
Share on other sites

@realkiller

I am not sure if this will do it.

#include <array.au3>

$Shell = Objcreate("WScript.Shell")
$File = ObjCreate("Scripting.FileSystemObject")


$Dom = ObjGet("WinNT://YOURDOMAIN")
$Dom.Filter = _ArrayCreate("computer")
$avail = 0

For $item in $Dom
    ping ($item.Name,$avail)
    if $avail = 1 then maclist $item.Name
next
ConsoleWrite ("MAC address capture complete...")
Exit

;---
;appends PC name and MAC address to macaddr.txt
Func macList($RemotePC)
    $IPConfigSet = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & _
    $RemotePC & "\root\cimv2" ).ExecQuery ("SELECT MACAddress FROM Win32_NetworkAdapterConfiguration " & "WHERE IPEnabled=true" )
    For $IPConfig In $IPConfigSet
        $custom = $RemotePC & @TAB & $IPConfig.MACAddress & $vbNewLine
    Next

    createTempfile ($custom)

    fileAppend ($File.OpenTextFile ("c:\temp.txt"), $File.OpenTextFile ("c:\macaddr.txt", 8))
    $File.DeleteFile ("c:\temp.txt", 1)
EndFunc


;---
;This function appends one $File to another
Func fileAppend($source,$destination)
    While $source.AtEndOfline (<> 1)
        $destination.WriteLine($source.readline)
    Wend

        $source.close()
        $destination.close()

EndFunc

;---
;creates a txt $File called $temp.txt and write;s data from $dat to it
Func createTempfile($dat)
        $temp = $File.CreateTextFile("c:\temp.txt")
        $temp.WriteLine ($dat)
        $temp.Close()
EndFunc


    ;---
    ;pings a client
    Func ping ($RemotePC,$avail)
        $objPing = ObjGet("winmgmts:{impersonationLevel=impersonat e}").ExecQuery("select * from Win32_PingStatus where address = '" & $RemotePC & "'")
        For $objStatus in $objPing
            If not IsObj($objStatus.StatusCode) or $objStatus.StatusCode<>0 Then
                $avail = 0
            Else
                $avail = 1
            EndIf
        Next
    EndFunc

Regards

ptrex

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

@RealKiller

Sorry for not testing it !!

I only did a quick translation.

This runs without errors (still not tested)

#include <array.au3>

$Shell = Objcreate("WScript.Shell")
$File = ObjCreate("Scripting.FileSystemObject")

$Dom = ObjGet("WinNT://DOMAIN")
$Dom.Filter = _ArrayCreate("computer")
$avail = 0

For $item in $Dom
    _Ping ($item.Name,$avail)
    if $avail = 1 then maclist ($item.Name)
next
ConsoleWrite ("MAC address capture complete...")
Exit

;appends PC name and MAC address to macaddr.txt
Func macList($RemotePC)
    $IPConfigSet = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & $RemotePC & "\root\cimv2")
    $IPConfigs = $IPConfigSet.ExecQuery ("SELECT MACAddress FROM Win32_NetworkAdapterConfiguration " & "WHERE IPEnabled=true" )
    For $IPConfig In $IPConfigs
        $custom = $RemotePC & @TAB & $IPConfig.MACAddress & @CRLF
    Next

    createTempfile ($custom)

    fileAppend ($File.OpenTextFile ("c:\temp.txt"), $File.OpenTextFile ("c:\macaddr.txt", 8))
    $File.DeleteFile ("c:\temp.txt", 1)
EndFunc

;This function appends one $File to another
Func fileAppend($source,$destination)
    While $source.AtEndOfline <> 1
        $destination.WriteLine($source.readline)
    Wend

        $source.close()
        $destination.close()
EndFunc

;creates a txt $File called $temp.txt and write;s data from $dat to it
Func createTempfile($dat)
        $temp = $File.CreateTextFile("c:\temp.txt")
        $temp.WriteLine ($dat)
        $temp.Close()
EndFunc

;pings a client
Func _Ping ($RemotePC,$avail)
        $objPing = ObjGet("winmgmts:{impersonationLevel=impersonate}")
        $Result = $objPing.ExecQuery("select * from Win32_PingStatus where address = '" & $RemotePC & "'")
        For $objStatus in $Result
            If not IsObj($objStatus.StatusCode) or $objStatus.StatusCode<>0 Then
                $avail = 0
            Else
                $avail = 1
            EndIf
        Next
EndFunc

regards,

ptrex

Edited by ptrex

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0