Extended Attribute - Using a Computer's IP Address

ekkehard
Contributor

Need to look up an ldapsearch attribute based on to create an extended attribute via a script and need to utilize the computer's IP Address. Can I access that in a script? If so how?

3 REPLIES 3

mm2270
Legendary Contributor III

You might need to clarify what you're looking for. Do you need the Mac to get its own IP address in the script? Or are you trying to get that information out of your JSS in your script?

ekkehard
Contributor

I'd like to have the script get the ip address from the computer record in the jss database.

mm2270
Legendary Contributor III

OK, so what information do you have regarding the Mac or Macs in question that you need to pull this info from the JSS? Computer name? Serial #? MAC Address? Several of these?

The way to do this would involve using the Casper API, calling the Mac's record via a script and parsing the data you need, in this case, the IP address reported to the JSS.

Rather than me posting some lengthy example, take a look at this thread, where Chris has posted a link to his blog on how to pull specific information from an API record. You can adapt that script to get the reported IP address back and then use that as a variable in your ldapsearch.
https://jamfnation.jamfsoftware.com/discussion.html?id=7052

Post back if you get lost along the way, but it should at least point you in the right direction.