1 /*        $NetBSD: LDAPObjClass.h,v 1.3 2021/08/14 16:14:49 christos Exp $      */
2 
3 // $OpenLDAP$
4 /*
5  * Copyright 2003-2021 The OpenLDAP Foundation, All Rights Reserved.
6  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
7  */
8 
9 #ifndef LDAP_OBJCLASS_H
10 #define LDAP_OBJCLASS_H
11 
12 #include <ldap_schema.h>
13 #include <string>
14 
15 #include "StringList.h"
16 
17 using namespace std;
18 
19 /**
20  * Represents the Object Class (from LDAP schema)
21  */
22 class LDAPObjClass{
23     private :
24           StringList names, must, may, sup;
25           string desc, oid;
26           int kind;
27 
28     public :
29 
30         /**
31          * Constructs an empty object.
32          */
33         LDAPObjClass();
34 
35         /**
36          * Copy constructor
37            */
38           LDAPObjClass( const LDAPObjClass& oc );
39 
40         /**
41            * Constructs new object and fills the data structure by parsing the
42            * argument.
43            * @param oc_item description of object class is string returned
44            * by the search command. It is in the form:
45            * "( SuSE.YaST.OC:5 NAME 'userTemplate' SUP objectTemplate STRUCTURAL
46            *    DESC 'User object template' MUST ( cn ) MAY ( secondaryGroup ))"
47          */
48         LDAPObjClass (string oc_item, int flags = LDAP_SCHEMA_ALLOW_NO_OID |
49                       LDAP_SCHEMA_ALLOW_QUOTED);
50 
51         /**
52          * Destructor
53          */
54         virtual ~LDAPObjClass();
55 
56           /**
57            * Returns object class description
58            */
59           string getDesc() const;
60 
61           /**
62            * Returns object class oid
63            */
64           string getOid() const;
65 
66           /**
67            * Returns object class name (first one if there are more of them)
68            */
69           string getName() const;
70 
71           /**
72            * Returns object class kind: 0=ABSTRACT, 1=STRUCTURAL, 2=AUXILIARY
73            */
74           int getKind() const;
75 
76           /**
77            * Returns all object class names
78            */
79           StringList getNames() const;
80 
81           /**
82            * Returns list of required attributes
83            */
84           StringList getMust() const;
85 
86           /**
87            * Returns list of allowed (and not required) attributes
88            */
89           StringList getMay() const;
90 
91         /**
92            * Returns list of the OIDs of the superior ObjectClasses
93            */
94           StringList getSup() const;
95 
96           void setNames (char **oc_names);
97           void setMay (char **oc_may);
98           void setMust (char **oc_must);
99           void setDesc (char *oc_desc);
100           void setOid (char *oc_oid);
101           void setKind (int oc_kind);
102           void setSup (char **oc_sup);
103 
104 };
105 
106 #endif // LDAP_OBJCLASS_H
107