I had previously posted, and got a reply to, a request to extract a specific portion of the Active directory path. However, in some cases the Active Directory Path shows the value, and the recommended relevance returns none. So I am asking again for assistance.
I am trying to get the 3rd OU from path. For example, the Active Directory Path returns:
CN= ComputerName, OU=DevType, OU=Value1, OU=Value2, and so forth
I want to simply have a property that displays the value of “Value1” in the example. The code recommend was:
if exists true whose (if true then exists distinguished name of local computer of active directory else false) then (following texts of first “=” of parenthesized part 3 of matches (regex "^(.),(.),(.),(.),(.),(.),(.),(.),(.)$") of distinguished name of local computer of active directory) else “”*
However, where some devices report “Value1” some = none
What’s the best relevance code to simply extract the 3rd set in Active Directory Path?
if exists true whose (if true then exists distinguished name of local computer of active directory else false) then (preceding text of first “,” of following text of first “=” of following text of first “,” of following text of first “,” of distinguished name of local computer of active directory) else ("")
The problem is that it is unknown how many differences there could be in the OU path. If this does not work for some, then we need to see some more examples to determine something better.
Thanks for the fast response. This is very similar to the original:
if exists true whose (if true then exists distinguished name of local computer of active directory else false) then (following texts of first “=” of parenthesized part 3 of matches (regex “^(.),(.),(.),(.),(.),(.),(.),(.),(.*)$”) of distinguished name of local computer of active directory) else “”
The best example I can give, without showing live data, is that when I pull a report I see that this code generates a “none” response where Active Directory Path generated CN=CompName, OU=Workstations, OU=Value1, OU=Value2, OU=Value3, and so forth.
Is there any way to concatenate the output of _BESClient_ActiveDirectoryPathOverride as called in Active Directory Path?
tuple string items 2 of (concatenations ", " of substrings separated by "," of it) of distinguished names of local computers of active directories
And this:
following texts of firsts "=" of tuple string items 2 of (concatenations ", " of substrings separated by "," of it) of distinguished names of local computers of active directories
I was able to confirm that these work on test systems.
You can use tuple string items # to get any arbitrary position in a string that is separated by a comma followed by a space.
I just discovered a Windows-Only inspector that helps get JUST the OU info from the computer’s distinguished name.
unique values of (concatenations ":" of values of components whose("OU" = type of it) of it) of (distinguished name it) of (distinguished names of local computers of it) of active directories
Then this will give just the 2nd part of the OU:
unique values of (tuple string items 1 of concatenations ", " of values of components whose("OU" = type of it) of it) of (distinguished name it) of (distinguished names of local computers of it) of active directories
The main drawback to this option is that it is Windows-Only, where parsing the text of the distinguished name instead will work on the Mac as well.