Skip to Content
Active Directory Cookbook
book

Active Directory Cookbook

by Robbie Allen
September 2003
Intermediate to advanced
624 pages
15h 49m
English
O'Reilly Media, Inc.
Content preview from Active Directory Cookbook

10.4. Generating a GUID to Use for a New Class or Attribute

Problem

You want to generate a GUID to use for the schemaIDGUID attribute of a new class or attribute you intend to add to the schema.

Solution

There are several ways to go about generating a GUID. If you do not specify the schemaIDGUID when initially creating a class or attribute, one will automatically be generated for you. So you could add the class or attribute to the schema of a test forest, and then use the schemaIDGUID that was generated in that forest.

You can also programmatically generate a GUID using Perl, VB, C++, or C#, but you cannot do it natively within VBScript. The Windows API supports a CoCreateGUID method that can be used to generate a GUID. If you are stuck with VBScript, you can wrap the CoCreateGUID method in an ActiveX DLL using VB and then use that DLL from within VBScript.

Finally, you can use a tool such as uuidgen.exe, which is available in the Microsoft Platform SDK to generate GUIDs. Uuidgen doesn’t require any parameters (although there are a few options that can be seen by running uuidgen -h), and it can generate as many GUIDs as you need.

If you intend to use LDIF files for extending the schema (highly recommended), then you need to encode any GUIDs in base64 notation. This is necessary because GUIDs are stored as octet strings (binary data) in Active Directory. The LDIF specification requires any binary data to be encoded in base64. Again, VBScript does not support base64 encoding natively, but ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Active Directory Administration Cookbook

Active Directory Administration Cookbook

Sander Berkouwer
Active Directory Cookbook, 3rd Edition

Active Directory Cookbook, 3rd Edition

Laura E. Hunter, Robbie Allen
Active Directory Cookbook, 4th Edition

Active Directory Cookbook, 4th Edition

Brian Svidergol, Robbie Allen

Publisher Resources

ISBN: 0596004648Supplemental ContentCatalog PageErrata