[ Team LiB ] |
Recipe 10.9 Adding a New Class10.9.1 ProblemYou want to add a new class to the schema. 10.9.2 Solution
10.9.2.1 Using a graphical user interface
10.9.2.2 Using a command-line interfaceYou can create new classes by using ldifde and an LDIF file that contains the properties to be set on the class. The following text shows an example LDIF file called create_class.ldf that creates a class called rallencorp-SalesUser: dn: cn=rallencorp-SalesUser,cn=schema,cn=configuration,<ForestRootDN> changetype: add objectclass: classSchema lDAPDisplayName: rallencorp-SalesUser governsId: 1.3.6.1.4.1.999.1.1.28.4 objectClassCategory: 3 subClassOf: top description: Auxiliary class for Sales user attributes adminDescription: Auxiliary class for Sales user attributes mayContain: rallencorp-Building mayContain: rallencorp-Theatre Then run the following command: > ldifde -v -i -f create_class.ldf 10.9.2.3 Using VBScript' This code creates a class in the schema called rallencorp-SalesUser. ' It is assumed that the script is being run by a member of Schema Admins set objRootDSE = GetObject("LDAP://RootDSE") set objSchemaCont = GetObject("LDAP://" & _ objRootDSE.Get("schemaNamingContext") ) set objClass = objSchemaCont.Create("classSchema", _ "cn=rallencorp-SalesUser") objClass.Put "lDAPDisplayName", "rallencorp-SalesUser" objClass.Put "governsId", "1.3.6.1.4.1.999.1.1.28.4" objClass.Put "objectClassCategory", 3 objClass.Put "subClassOf", "top" objClass.Put "adminDescription", "Languages a user speaks" objClass.Put "mayContain", Array("rallencorp-Building","rallencorp-Theatre") objClass.SetInfo WScript.Echo "Class created" 10.9.3 DiscussionTo create a new class, you need to create a classSchema object in the Schema container. The important attributes to set include:
The lDAPDisplayName also needs to be set and should be equal to the common name (cn) as a general rule. Even though many of the default classes do not use the same name for the common name and LDAP display name, using the same name is highly recommended to avoid confusion when referencing the class. Another best practice is to set the schemaIDGUID of the class, which is especially important if you are doing anything with extended rights. The See Also section contains references to recipes that cover some of these topics in more depth. 10.9.4 See AlsoIntroduction in Chapter 10 for attributes of classSchema objects, Recipe 10.3 for generating an OID, Recipe 10.4 for generating a GUID, Recipe 10.17 for more on object class type, Recipe 10.19 for setting the default security for a class, and Recipe 10.22 for reloading the schema cache |
[ Team LiB ] |