Thursday, July 20, 2006


Create Clean Schema File from AD/AM

Have you ever wanted to get a nice clean schema file containing all of your custom attirbutes and object class entries but exluding the special microsofty attributes from and AD/AM (or AD) instance so that you can archive it off into a source control system or just simply migrate it to another environment? You dread the task becuase you never took the time to automate it so you always edit the file by hand. Well here is a simple regex that you can use to clean up the file after you extract it. The regex as written works in editplus (by far the best editor I have ever used, come on buy it, you know you want to), but can can be easily tweaked to work in other editors, scripts, etc.

Anyway, there are three steps...
  1. Extract your data... here is the ldifde way
    ldifde -f {filename} -s {server} -t {port}
    -d "CN=schema,CN=configuration,CN={adam_guid}"
    -r {custom object searhc filter}

  2. Prune the unwanted attributes

    In the following section it should all be read as a single regex (ignore line breaks). It should be used in a substitution statement where nothing is substituted for the match.

    ::? [^\n]*\n( [^\n]+\n)*
  3. Replace the AD/AM GUID

    to make it really easy to import into a target environment change the GUID in the file to something easy to type that is not repeated elsewhere in the file.

    For ldifde (not sure about other ldif tools offhand) you could also just use the -o arg to omit attributes you don't want.
    Post a Comment

    << Home

    This page is powered by Blogger. Isn't yours?