Forum Discussion
Kai_Wilke
Apr 12, 2019MVP
Hi Jim,
if your CN values MAY contain escaped comma signs (aka. $1 sequence), then use one of the code snippet(s) below. The snippet(s) will check for those escaped comma signs and take care of them...
Short but difficult to understand snipped:
set group_string [mcget "session.ldap.last.attr.memberOf "] ;
if { $group_string contains "\\," } then {
return [string map { "" "\\," } [string range [set escaped_group_string [string map { "\\," "" } $group_string]] [expr { [string first "CN=" $escaped_group_string] + 3 }] [expr { [string first "," $escaped_group_string] -1 }]]] ;
} else {
return [string range $group_string [expr { [string first "CN=" $group_string] + 3 }] [expr { [string first "," $group_string] -1 }]] ;
} ;
Long but easy to understand snipped:
set group_string [mcget "session.ldap.last.attr.memberOf "] ;
if { $group_string contains "\\," } then {
set escaped_group_string [string map { "\\," "" } $group_string];
set string_start [expr { [string first "CN=" $escaped_group_string] + 3 }] ;
set string_stop [expr { [string first "," $escaped_group_string] -1 }] ;
set escaped_result_string [string range $escaped_group_string $string_start $string_stop] ;
set result_string [string map { "" "\\," } $escaped_result_string] ;
return $result_string ;
} else {
set string_start [expr { [string first "CN=" $group_string] + 3 }] ;
set string_stop [expr { [string first "," $group_string] -1 }] ;
set result_string [string range $group_string $string_start $string_stop] ;
return $result_string ;
} ;
Cheers, Kai