Forum Discussion

Stig_hj's avatar
Stig_hj
Copper Contributor
Jul 17, 2020

How to extract Common name from Distinguished Name in Kusto Query

Hi

Anyone have a Solution on how to extract Common name from Distinguished Name In Kusto I have tried parse, split, Sub string and what ever, but haven´t have a success with VB and Power Shell it is simple and a lot of examples to grab

 

From a table called Member Name  containing

CN=test test, OU=something, OU=Something, OU=Something

 

would like to display only the Name in output table

 Test Test

 

 

  • Stig_hj 

     

    Here are two ways, I prefer Parse to split in this case:

    let MemberTable = datatable (cn:string)
    [
    "CN=test test, OU=something, OU=Something, OU=Something"
    ];
    MemberTable
    | parse cn with * "CN=" strcnName "," *
    | project split(split(cn,",").[0],"=").[1] , strcnName

     

  • Stig_hj 

     

    Here are two ways, I prefer Parse to split in this case:

    let MemberTable = datatable (cn:string)
    [
    "CN=test test, OU=something, OU=Something, OU=Something"
    ];
    MemberTable
    | parse cn with * "CN=" strcnName "," *
    | project split(split(cn,",").[0],"=").[1] , strcnName

     

    • Stig_hj's avatar
      Stig_hj
      Copper Contributor

      CliveWatson  

      Thanks for your reply, had parse and split in the loop, but could not get a clean output 

      got something like [cn=Name Name]

      instead of Name Name

      • CliveWatson's avatar
        CliveWatson
        Icon for Microsoft rankMicrosoft

        Stig_hj 

         

        Maybe this a JSON rather than a string?

        Could you copy & paste one line of the real output from the real table?  Please remove any PII but leave the format!

        e.g.

         

        MemberTable
        | limit 1

         

Resources