JSI Tip 9847. How do I extract the container or OU from a distinguishedName?


I have scripted GetOUCN.bat to extract the container or OU from a distinguishedName.

The syntax for using GetOUCN.bat is:

call GetOUCN DN ID OUCN

Where:

DN   is the distinguishedName.

ID   is a call directed environment variable that will contain the letters CN or OU.

OUCN is a call directed environment variable that will contain the container or OU name.
GetOUCN.bat contains:
@echo off
if \{%3\}

\{\} @echo Syntax: GetOUCN DN ID OUCN&goto :EOF for /f "Tokens=2 Delims=," %%a in ('@echo %1') do ( for /f "Tokens=1* Delims

" %%b in ('@echo %%a') do ( set %2=%%b set %3=%%c ) )



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish