Documentation ¶
Overview ¶
Package schemax provides methods, types and bidirectional marshaling functionality intended for use in the area of X.501/LDAP directory schema abstraction.
Types provided by this package are created based on the precepts of RFC2252 and RFC4512, as are the associated parsing techniques (e.g.: 'qdescrs', etc.). A variety of methods and functions exist to make handling this data simpler.
Abstract ¶
LDAP directories contain and serve data in a hierarchical manner. The syntax and evaluation of this data is governed by a schema, which itself is hierarchical in nature.
The nature of this package's operation is highly referential. Objects are referenced via pointers, and these objects can inhabit multiple other multi-valued types. For example, *AttributeType instances are stored within a type-specific slices called Collections. Each *AttributeType that exists can be referenced by other *AttributeType instances (in a scenario where "super typing" is in effect), or by other *ObjectClass instances via their own PermittedAttributeTypes (May) and RequiredAttributeTypes (Must) list types. Literal "copies" of single objects are never made. References are always through pointers.
Intended Audience ¶
This package is primarily intended for any architect, developer or analyst looking to do one or more of the following:
• Parse (Marshal) textual LDAP schema definitions into objects
• Unmarshal objects into textual LDAP schema definitions
• Work with data models and structures that may represent or contain some facet of a schema
Parsing ¶
This package aims to provide a fast, reliable, standards-compliant parsing routine for LDAP schema definitions into discrete, useful objects. Parsing of raw values during the Marshal operation is conducted without the use of the regexp package, nor any facility based on regular expressions. Instead, precise byte-for-byte parsing/truncation of raw definitions is conducted, during which time known flags (or labels) are identified for specialized handling (e.g.: NAME).
For successful parsing, each definition must be limited to a single line when an entire schema file is streamed line-by-line. Future releases of this package will relax this requirement. However, when marshaling single definitions, multi-line definitions are supported. Line feeds are removed outright, and recurring WHSP characters (spaces/tabs) are reduced to single spaces between fields.
Population Order ¶
When POPULATING various collection types (e.g.: slices of definitions), the following "order of operations" MUST be honored:
1. LDAPSyntaxes
2. MatchingRules
3. AttributeTypes
4. MatchingRuleUses
5. ObjectClasses
6. DITContentRules
7. NameForms
8. DITStructureRules
Individually, collections containing the above elements should also be populated in order of referential superiority. For example, all independent instances should be populated before those that depend upon them, such as in the cases of sub-types, sub-classes and sub-rules.
An obvious real-world example of this is for the 'name' attribute (per RFC4519), which is a super-type of several other key attribute types. In such a case, those definitions that depend (or are based) upon the 'name' attribute WILL NOT MARSHAL until 'name' has been marshaled itself.
This logic applies no matter how the definitions are being received (or "read"), and applies whether or not the all-encompassing Subschema type is used. In short: MIND YOUR ORDERING.
Iterating Collections ¶
Iterating a collection type, such as AttributeTypeCollection instances, MUST be done using the Len() collection method, e.g.:
for i := 0; i < attrs.Len(); i++ { attr := attrs.Index(i) ... do stuff ... }
Iteration will always returns collection members in FIFO ordering (First-In/First-Out).
Standard Definitions ¶
Within subdirectories of this package are popular Go implementations of standard Attribute Types, Object Classes, Matching Rules and LDAP Syntaxes from RFCs that are recognized (almost) universally. This includes (but is not limited to) content from RFC4512, RFC4519 and RFC2307. Included in each subdirectory is an unmodified text copy of the Internet-Draft from which the relevant definitions originate.
The user is advised that some LDAP implementations have certain attribute types and object classes "built-in" and are not sourced from a schema file like others (rather they likely are compiled-in to the product).
This varies between implementations and, as such, inconsistencies may arise for someone using this product across various directory products. One size absolutely does not fit all. In such a case, an attempt to marshal a schema file may fail due to unsatisfied super-type or super-class(es) dependencies. To mitigate this, the user must somehow provide the lacking definitions, either by themselves or using one of the subdirectory packages.
OID Macros ¶
Also known as OID "aliases", macros allow a succinct expression of an OID prefix by way of a text identifier. As a real-world example, RFC2307 uses the alias "nisSchema" to describe the OID prefix of "1.3.6.1.1.1".
This package supports the registration and use of such aliases within the Macros map type. Note that this is an all-or-nothing mechanism. Understand that if a non-nil Macros instance is detected, and unregistered aliases are encountered during a parsing run, normal operations will be impacted. As such, users are advised to anticipate any aliases needed in advance or to abolish their use altogether.
OID aliasing supports both dot (.) and colon (:) runes for delimitation, thus 'nisSchema.1.1' and 'nisSchema:1.1' are acceptable.
Custom Unmarshalers ¶
By default, definitions are unmarshaled as single-line string values. This package supports the creation of user-authored closure functions to allow customization of this behavior. As a practical example, users may opt to write a function to convert definitions to individual CSV rows, or perhaps JSON objects -- literally anything, so long as it is a string.
Each definition type comes with a default (optional) UnmarshalFunc instance. This, or any custom function, can be invoked by-name as follows:
myfunc := UnmarshalerFuncName // Must conform to the DefinitionUnmarshaler signature! def.SetUnmarshaler(myfunc) // assign the function by name to your definition raw, err := schemax.Unmarshal(def) // unmarshal ...
In the above example, the definition would unmarshal as a standard RFC4512 schema definition, but with linebreaks and indenting added. This must be done for EVERY definition being unmarshaled.
User-authored functions MUST honor the following function signature (see the DefinitionUnmarshaler type for details).
func(any) (string, error)
The structure of a given user-authored unmarshaler function will vary, but should generally reflect the example below.
// Example attributeType unmarshaler func myCustomAttributeUnmarshaler(x any) (def string, err error) { // We'll use this variable to store the // value once we verify it's copacetic. var r *AttributeType // As you can clearly see in the signature, the user // will provide a value as an interface. We'll need // to type-assert whatever they provide to ensure // its the exact type we are prepared to handle. switch tv := x.(type) { case *AttributeType: if tv.IsZero() { err = fmt.Errorf("%T is nil", tv) return } r = tv default: err = fmt.Errorf("Bad type for unmarshal (%T)", tv) return } // // <<Your custom attributeType-handling code would go here>> // return } // ... later in your code ... // // This can be applied to a single definition // -OR- a collection of definitions! obj.SetUnmarshaler(myCustomAttributeUnmarshaler)
Map Unmarshaler ¶
For added convenience, each definition includes a Map() method that returns a map[string][]string instance containing the effective contents of said definition. This is useful in situations where the user is more interested in simple access to string values in fields, as opposed to the complicated traversal of pointer instances that may exist within a definition.
defmap := def.Map() if value, exists := defmap[`SYNTAX`]; exists { val := value[0] fmt.Printf("Syntax OID is: %s\n", val) }
Naturally, ordering of fields is lost due to use of a map in this fashion. It is up to the consuming application to ensure correct ordering of fields as described in RFC4512 section 4.1, wherever applicable.
Extended Information ¶
Each definition supports the optional assignment of a []byte value containing "extended information", which can literally be anything (pre-rendered HTML, or even Graphviz content to name a few potential use cases). This package imposes no restrictions of any kind regarding the nature or length of the assigned byte slice.
The main purpose of this functionality is to allow the user to annotate information that goes well beyond the terse DESC field value normally present within definitions.
info := []byte(`<html>...</html>`) def.SetInfo(info) ... fmt.Printf("%s\n", string(def.Info()))
Index ¶
- Constants
- Variables
- func AttributeTypeUnmarshaler(x any) (def string, err error)
- func DITContentRuleUnmarshaler(x any) (def string, err error)
- func DITStructureRuleUnmarshaler(x any) (def string, err error)
- func LDAPSyntaxUnmarshaler(x any) (def string, err error)
- func Marshal(raw string, x any, atc AttributeTypeCollection, occ ObjectClassCollection, ...) (err error)
- func MatchingRuleUnmarshaler(x any) (def string, err error)
- func MatchingRuleUseUnmarshaler(x any) (def string, err error)
- func NameFormUnmarshaler(x any) (def string, err error)
- func ObjectClassUnmarshaler(x any) (def string, err error)
- func PopulateRFC2079AttributeTypes(atc AttributeTypeCollection, lsc LDAPSyntaxCollection, ...)
- func PopulateRFC2079ObjectClasses(occ ObjectClassCollection, atc AttributeTypeCollection, ...)
- func PopulateRFC2307AttributeTypes(atc AttributeTypeCollection, lsc LDAPSyntaxCollection, ...)
- func PopulateRFC2307MatchingRules(lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
- func PopulateRFC2307ObjectClasses(occ ObjectClassCollection, atc AttributeTypeCollection, ...)
- func PopulateRFC2307Syntaxes(lsc LDAPSyntaxCollection)
- func PopulateRFC2798AttributeTypes(atc AttributeTypeCollection, lsc LDAPSyntaxCollection, ...)
- func PopulateRFC2798ObjectClasses(occ ObjectClassCollection, atc AttributeTypeCollection, ...)
- func PopulateRFC3045AttributeTypes(atc AttributeTypeCollection, lsc LDAPSyntaxCollection, ...)
- func PopulateRFC3672AttributeTypes(atc AttributeTypeCollection, lsc LDAPSyntaxCollection, ...)
- func PopulateRFC3672ObjectClasses(occ ObjectClassCollection, atc AttributeTypeCollection, ...)
- func PopulateRFC4512AttributeTypes(atc AttributeTypeCollection, lsc LDAPSyntaxCollection, ...)
- func PopulateRFC4512ObjectClasses(occ ObjectClassCollection, atc AttributeTypeCollection, ...)
- func PopulateRFC4517MatchingRules(lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
- func PopulateRFC4517Syntaxes(lsc LDAPSyntaxCollection)
- func PopulateRFC4519AttributeTypes(atc AttributeTypeCollection, lsc LDAPSyntaxCollection, ...)
- func PopulateRFC4519ObjectClasses(occ ObjectClassCollection, atc AttributeTypeCollection, ...)
- func PopulateRFC4523AttributeTypes(atc AttributeTypeCollection, lsc LDAPSyntaxCollection, ...)
- func PopulateRFC4523MatchingRules(lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
- func PopulateRFC4523ObjectClasses(occ ObjectClassCollection, atc AttributeTypeCollection, ...)
- func PopulateRFC4523Syntaxes(lsc LDAPSyntaxCollection)
- func PopulateRFC4524AttributeTypes(atc AttributeTypeCollection, lsc LDAPSyntaxCollection, ...)
- func PopulateRFC4524ObjectClasses(occ ObjectClassCollection, atc AttributeTypeCollection, ...)
- func PopulateRFC4530AttributeTypes(atc AttributeTypeCollection, lsc LDAPSyntaxCollection, ...)
- func PopulateRFC4530MatchingRules(lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
- func PopulateRFC4530Syntaxes(lsc LDAPSyntaxCollection)
- func Unmarshal(x any) (string, error)
- type ApplicableAttributeTypes
- type AttributeType
- func (r *AttributeType) Collective() bool
- func (r *AttributeType) Equal(x any) (eq bool)
- func (r *AttributeType) HumanReadable() bool
- func (r *AttributeType) Info() []byte
- func (r *AttributeType) IsZero() bool
- func (r *AttributeType) Map() (def map[string][]string)
- func (r *AttributeType) MaxLength() int
- func (r *AttributeType) NoUserModification() bool
- func (r *AttributeType) SetCollective()
- func (r *AttributeType) SetInfo(info []byte)
- func (r *AttributeType) SetMaxLength(max int)
- func (r *AttributeType) SetNoUserModification()
- func (r *AttributeType) SetSingleValue()
- func (r *AttributeType) SetSpecifier(spec string)
- func (r *AttributeType) SetUnmarshaler(fn DefinitionUnmarshaler)
- func (r *AttributeType) SingleValue() bool
- func (r *AttributeType) String() (def string)
- func (r *AttributeType) Type() string
- func (r *AttributeType) Validate() (err error)
- type AttributeTypeCollection
- func NewApplicableAttributeTypes() AttributeTypeCollection
- func NewAttributeTypes() AttributeTypeCollection
- func NewPermittedAttributeTypes() AttributeTypeCollection
- func NewProhibitedAttributeTypes() AttributeTypeCollection
- func NewRequiredAttributeTypes() AttributeTypeCollection
- func PopulateDefaultAttributeTypes() (atc AttributeTypeCollection)
- type AttributeTypes
- func (r *AttributeTypes) Contains(x any) (int, bool)
- func (r *AttributeTypes) Equal(x AttributeTypeCollection) bool
- func (r *AttributeTypes) Get(x any) *AttributeType
- func (r *AttributeTypes) Index(idx int) *AttributeType
- func (r *AttributeTypes) IsZero() bool
- func (r AttributeTypes) Label() string
- func (r AttributeTypes) Len() int
- func (r *AttributeTypes) Set(x *AttributeType) error
- func (r *AttributeTypes) SetMacros(macros *Macros)
- func (r *AttributeTypes) SetSpecifier(spec string)
- func (r *AttributeTypes) SetUnmarshaler(fn DefinitionUnmarshaler)
- func (r *AttributeTypes) String() string
- type AuxiliaryObjectClasses
- type DITContentRule
- func (r *DITContentRule) Belongs(aux *ObjectClass) (belongs bool)
- func (r *DITContentRule) Equal(x any) (eq bool)
- func (r *DITContentRule) Info() []byte
- func (r *DITContentRule) IsZero() bool
- func (r *DITContentRule) Map() (def map[string][]string)
- func (r *DITContentRule) Permits(x any) (permitted bool)
- func (r *DITContentRule) Prohibits(x any) (prohibited bool)
- func (r *DITContentRule) Requires(x any) (required bool)
- func (r *DITContentRule) SetInfo(info []byte)
- func (r *DITContentRule) SetSpecifier(spec string)
- func (r *DITContentRule) SetUnmarshaler(fn DefinitionUnmarshaler)
- func (r DITContentRule) String() (def string)
- func (r *DITContentRule) Type() string
- func (r *DITContentRule) Validate() (err error)
- type DITContentRuleCollection
- type DITContentRules
- func (r DITContentRules) Contains(x any) (int, bool)
- func (r DITContentRules) Equal(x DITContentRuleCollection) bool
- func (r DITContentRules) Get(x any) *DITContentRule
- func (r DITContentRules) Index(idx int) *DITContentRule
- func (r DITContentRules) IsZero() bool
- func (r DITContentRules) Label() string
- func (r DITContentRules) Len() int
- func (r *DITContentRules) Set(x *DITContentRule) error
- func (r *DITContentRules) SetMacros(macros *Macros)
- func (r *DITContentRules) SetSpecifier(spec string)
- func (r *DITContentRules) SetUnmarshaler(fn DefinitionUnmarshaler)
- func (r DITContentRules) String() string
- type DITStructureRule
- func (r *DITStructureRule) Equal(x any) (eq bool)
- func (r *DITStructureRule) Info() []byte
- func (r *DITStructureRule) IsZero() bool
- func (r *DITStructureRule) Map() (def map[string][]string)
- func (r *DITStructureRule) SetInfo(info []byte)
- func (r *DITStructureRule) SetSpecifier(spec string)
- func (r *DITStructureRule) SetUnmarshaler(fn DefinitionUnmarshaler)
- func (r DITStructureRule) String() (def string)
- func (r *DITStructureRule) Type() string
- func (r *DITStructureRule) Validate() (err error)
- type DITStructureRuleCollection
- type DITStructureRules
- func (r DITStructureRules) Contains(x any) (int, bool)
- func (r DITStructureRules) Equal(x DITStructureRuleCollection) bool
- func (r DITStructureRules) Get(x any) *DITStructureRule
- func (r DITStructureRules) Index(idx int) *DITStructureRule
- func (r *DITStructureRules) IsZero() bool
- func (r DITStructureRules) Label() string
- func (r DITStructureRules) Len() int
- func (r *DITStructureRules) Set(x *DITStructureRule) error
- func (r *DITStructureRules) SetSpecifier(spec string)
- func (r *DITStructureRules) SetUnmarshaler(fn DefinitionUnmarshaler)
- func (r DITStructureRules) String() string
- type Definition
- type DefinitionUnmarshaler
- type Description
- type Equality
- type Extension
- type Extensions
- func (r Extensions) Contains(x any) (int, bool)
- func (r Extensions) Equal(x any) (eq bool)
- func (r Extensions) Exists(label string) (exists bool)
- func (r Extensions) Get(label string) *Extension
- func (r Extensions) HumanReadable() bool
- func (r Extensions) Index(idx int) *Extension
- func (r *Extensions) IsZero() bool
- func (r Extensions) Label() string
- func (r Extensions) Len() int
- func (r *Extensions) Set(x ...any)
- func (r *Extensions) SetHumanReadable(x bool)
- func (r Extensions) String() (exts string)
- type Kind
- type LDAPSyntax
- func (r *LDAPSyntax) Equal(x any) (eq bool)
- func (r *LDAPSyntax) HumanReadable() bool
- func (r *LDAPSyntax) Info() []byte
- func (r *LDAPSyntax) IsZero() bool
- func (r LDAPSyntax) Label() string
- func (r *LDAPSyntax) Map() (def map[string][]string)
- func (r *LDAPSyntax) SetHumanReadable(x bool)
- func (r *LDAPSyntax) SetInfo(info []byte)
- func (r *LDAPSyntax) SetSpecifier(spec string)
- func (r *LDAPSyntax) SetUnmarshaler(fn DefinitionUnmarshaler)
- func (r LDAPSyntax) String() (def string)
- func (r *LDAPSyntax) Type() string
- func (r *LDAPSyntax) Validate() (err error)
- type LDAPSyntaxCollection
- type LDAPSyntaxes
- func (r LDAPSyntaxes) Contains(x any) (int, bool)
- func (r LDAPSyntaxes) Equal(x LDAPSyntaxCollection) bool
- func (r LDAPSyntaxes) Get(x any) *LDAPSyntax
- func (r LDAPSyntaxes) Index(idx int) *LDAPSyntax
- func (r LDAPSyntaxes) IsZero() bool
- func (r LDAPSyntaxes) Label() string
- func (r LDAPSyntaxes) Len() int
- func (r *LDAPSyntaxes) Set(x *LDAPSyntax) error
- func (r *LDAPSyntaxes) SetMacros(macros *Macros)
- func (r *LDAPSyntaxes) SetSpecifier(spec string)
- func (r *LDAPSyntaxes) SetUnmarshaler(fn DefinitionUnmarshaler)
- func (r LDAPSyntaxes) String() string
- type Macros
- type MatchingRule
- func (r *MatchingRule) Equal(x any) (eq bool)
- func (r *MatchingRule) Info() []byte
- func (r *MatchingRule) IsZero() bool
- func (r *MatchingRule) Map() (def map[string][]string)
- func (r *MatchingRule) SetInfo(info []byte)
- func (r *MatchingRule) SetSpecifier(spec string)
- func (r *MatchingRule) SetUnmarshaler(fn DefinitionUnmarshaler)
- func (r MatchingRule) String() (def string)
- func (r *MatchingRule) Type() string
- func (r *MatchingRule) Validate() (err error)
- type MatchingRuleCollection
- type MatchingRuleUse
- func (r *MatchingRuleUse) Equal(x any) (eq bool)
- func (r *MatchingRuleUse) Info() []byte
- func (r *MatchingRuleUse) IsZero() bool
- func (r *MatchingRuleUse) Map() (def map[string][]string)
- func (r *MatchingRuleUse) SetInfo(info []byte)
- func (r *MatchingRuleUse) SetSpecifier(spec string)
- func (r *MatchingRuleUse) SetUnmarshaler(fn DefinitionUnmarshaler)
- func (r MatchingRuleUse) String() (def string)
- func (r *MatchingRuleUse) Type() string
- func (r *MatchingRuleUse) Validate() (err error)
- type MatchingRuleUseCollection
- type MatchingRuleUses
- func (r MatchingRuleUses) Contains(x any) (int, bool)
- func (r MatchingRuleUses) Equal(x MatchingRuleUseCollection) bool
- func (r MatchingRuleUses) Get(x any) *MatchingRuleUse
- func (r MatchingRuleUses) Index(idx int) *MatchingRuleUse
- func (r MatchingRuleUses) IsZero() bool
- func (r MatchingRuleUses) Label() string
- func (r MatchingRuleUses) Len() int
- func (r *MatchingRuleUses) Refresh(atc AttributeTypeCollection) (err error)
- func (r *MatchingRuleUses) Set(x *MatchingRuleUse) error
- func (r *MatchingRuleUses) SetSpecifier(spec string)
- func (r *MatchingRuleUses) SetUnmarshaler(fn DefinitionUnmarshaler)
- func (r MatchingRuleUses) String() string
- type MatchingRules
- func (r MatchingRules) Contains(x any) (int, bool)
- func (r MatchingRules) Equal(x MatchingRuleCollection) bool
- func (r MatchingRules) Get(x any) *MatchingRule
- func (r MatchingRules) Index(idx int) *MatchingRule
- func (r MatchingRules) IsZero() bool
- func (r MatchingRules) Label() string
- func (r MatchingRules) Len() int
- func (r *MatchingRules) Set(x *MatchingRule) error
- func (r *MatchingRules) SetMacros(macros *Macros)
- func (r *MatchingRules) SetSpecifier(spec string)
- func (r *MatchingRules) SetUnmarshaler(fn DefinitionUnmarshaler)
- func (r MatchingRules) String() string
- type Name
- type NameForm
- func (r *NameForm) Equal(x any) (eq bool)
- func (r *NameForm) Info() []byte
- func (r *NameForm) IsZero() bool
- func (r NameForm) Label() string
- func (r *NameForm) Map() (def map[string][]string)
- func (r *NameForm) SetInfo(info []byte)
- func (r *NameForm) SetSpecifier(spec string)
- func (r *NameForm) SetUnmarshaler(fn DefinitionUnmarshaler)
- func (r NameForm) String() (def string)
- func (r *NameForm) Type() string
- func (r *NameForm) Validate() (err error)
- type NameFormCollection
- type NameForms
- func (r NameForms) Contains(x any) (int, bool)
- func (r NameForms) Equal(x NameFormCollection) bool
- func (r NameForms) Get(x any) *NameForm
- func (r NameForms) Index(idx int) *NameForm
- func (r NameForms) IsZero() bool
- func (r NameForms) Label() string
- func (r NameForms) Len() int
- func (r *NameForms) Set(x *NameForm) error
- func (r *NameForms) SetMacros(macros *Macros)
- func (r *NameForms) SetSpecifier(spec string)
- func (r *NameForms) SetUnmarshaler(fn DefinitionUnmarshaler)
- func (r NameForms) String() string
- type OID
- type ObjectClass
- func (r *ObjectClass) Equal(x any) (eq bool)
- func (r *ObjectClass) Info() []byte
- func (r *ObjectClass) IsZero() bool
- func (r *ObjectClass) Map() (def map[string][]string)
- func (r *ObjectClass) SetInfo(info []byte)
- func (r *ObjectClass) SetSpecifier(spec string)
- func (r *ObjectClass) SetUnmarshaler(fn DefinitionUnmarshaler)
- func (r ObjectClass) String() (def string)
- func (r *ObjectClass) Type() string
- func (r *ObjectClass) Validate() (err error)
- type ObjectClassCollection
- type ObjectClasses
- func (r ObjectClasses) Contains(x any) (int, bool)
- func (r ObjectClasses) Equal(x ObjectClassCollection) bool
- func (r ObjectClasses) Get(x any) *ObjectClass
- func (r ObjectClasses) Index(idx int) *ObjectClass
- func (r *ObjectClasses) IsZero() bool
- func (r ObjectClasses) Label() string
- func (r ObjectClasses) Len() int
- func (r *ObjectClasses) Set(x *ObjectClass) error
- func (r *ObjectClasses) SetMacros(macros *Macros)
- func (r *ObjectClasses) SetSpecifier(spec string)
- func (r *ObjectClasses) SetUnmarshaler(fn DefinitionUnmarshaler)
- func (r ObjectClasses) String() string
- type Ordering
- type PermittedAttributeTypes
- type ProhibitedAttributeTypes
- type RequiredAttributeTypes
- type RuleID
- type StructuralObjectClass
- type Subschema
- func (r *Subschema) GetAttributeType(x string) *AttributeType
- func (r Subschema) GetDITContentRule(x string) *DITContentRule
- func (r Subschema) GetDITStructureRule(x string) *DITStructureRule
- func (r Subschema) GetLDAPSyntax(x string) *LDAPSyntax
- func (r Subschema) GetMatchingRule(x string) *MatchingRule
- func (r Subschema) GetMatchingRuleUse(x string) *MatchingRuleUse
- func (r Subschema) GetNameForm(x string) *NameForm
- func (r Subschema) GetObjectClass(x string) *ObjectClass
- func (r *Subschema) MarshalAttributeType(def string) (err error)
- func (r *Subschema) MarshalDITContentRule(def string) (err error)
- func (r *Subschema) MarshalDITStructureRule(def string) (err error)
- func (r *Subschema) MarshalLDAPSyntax(def string) (err error)
- func (r *Subschema) MarshalMatchingRule(def string) (err error)
- func (r *Subschema) MarshalNameForm(def string) (err error)
- func (r *Subschema) MarshalObjectClass(def string) (err error)
- func (r *Subschema) PopulateDefaultAttributeTypes()
- func (r *Subschema) PopulateDefaultLDAPSyntaxes()
- func (r *Subschema) PopulateDefaultMatchingRules()
- func (r *Subschema) PopulateDefaultObjectClasses()
- func (r *Subschema) SetAttributeType(x *AttributeType) (ok bool)
- func (r *Subschema) SetDITContentRule(x *DITContentRule) (ok bool)
- func (r *Subschema) SetDITStructureRule(x *DITStructureRule) (ok bool)
- func (r *Subschema) SetLDAPSyntax(x *LDAPSyntax) (ok bool)
- func (r *Subschema) SetMatchingRule(x *MatchingRule) (ok bool)
- func (r *Subschema) SetMatchingRuleUse(x *MatchingRuleUse) (ok bool)
- func (r *Subschema) SetNameForm(x *NameForm) (ok bool)
- func (r *Subschema) SetObjectClass(x *ObjectClass) (ok bool)
- type Substring
- type SuperiorAttributeType
- type SuperiorDITStructureRules
- type SuperiorObjectClasses
- type Usage
Examples ¶
- ApplicableAttributeTypes.Label
- AttributeType (ManualComposition)
- AttributeType.Equal
- AttributeType.IsZero
- AttributeType.Map
- AttributeType.MaxLength
- AttributeType.SetMaxLength
- AttributeType.SingleValue
- AttributeTypes.Contains
- AttributeTypes.Equal
- AttributeTypes.Get
- AttributeTypes.IsZero
- AttributeTypes.Set
- AuxiliaryObjectClasses.Label
- DITContentRule (ManualComposition)
- DITContentRule.Equal
- DITContentRule.IsZero
- DITContentRule.Map
- DITContentRules.Contains
- DITContentRules.Equal
- DITContentRules.Get
- DITContentRules.Set
- DITStructureRule (ManualComposition)
- DITStructureRule.Equal
- DITStructureRule.IsZero
- DITStructureRule.Map
- Equality.Label
- Extensions.Label
- Kind.Label
- LDAPSyntax (ManualComposition)
- LDAPSyntax.Equal
- LDAPSyntax.HumanReadable
- LDAPSyntax.IsZero
- LDAPSyntax.Label
- LDAPSyntax.Map
- LDAPSyntaxes.Contains
- LDAPSyntaxes.Equal
- LDAPSyntaxes.Get
- Marshal (NewAttributeType)
- Marshal (NewDITContentRule)
- Marshal (NewDITStructureRule)
- Marshal (NewLDAPSyntax)
- Marshal (NewMatchingRule)
- Marshal (NewNameForm)
- Marshal (NewObjectClass)
- MatchingRule (ManualComposition)
- MatchingRule.Equal
- MatchingRule.IsZero
- MatchingRule.Map
- MatchingRuleUse (ManualComposition)
- MatchingRuleUse.IsZero
- MatchingRuleUse.Map
- MatchingRules.Equal
- Name.IsZero
- NameForm (ManualComposition)
- NameForm.IsZero
- NameForm.Map
- NewApplicableAttributeTypes
- NewAttributeTypes
- NewAuxiliaryObjectClasses
- NewDITContentRules
- NewDITStructureRules
- NewExtensions
- NewLDAPSyntaxes
- NewMatchingRuleUses
- NewMatchingRules
- NewNameForms
- NewObjectClasses
- NewPermittedAttributeTypes
- NewProhibitedAttributeTypes
- NewRequiredAttributeTypes
- NewSubschema
- NewSuperiorDITStructureRules
- NewSuperiorObjectClasses
- ObjectClass (ManualComposition)
- ObjectClass.Equal
- ObjectClass.IsZero
- ObjectClass.Map
- ObjectClasses.Contains
- ObjectClasses.Equal
- ObjectClasses.Get
- ObjectClasses.IsZero
- Ordering.Label
- PermittedAttributeTypes.Label
- PopulateDefaultAttributeTypes
- ProhibitedAttributeTypes.Label
- RequiredAttributeTypes.Label
- Subschema.MarshalAttributeType
- Subschema.MarshalDITContentRule
- Subschema.MarshalDITStructureRule
- Subschema.MarshalLDAPSyntax
- Subschema.MarshalMatchingRule
- Subschema.MarshalNameForm
- Subschema.MarshalObjectClass
- Substring.Label
- SuperiorAttributeType.Label
- SuperiorDITStructureRules.Label
- SuperiorObjectClasses.Label
- Unmarshal
- Usage.Label
Constants ¶
const ( SingleValue atFlags = 1 << iota // 1 Collective // 2 NoUserModification // 4 )
Variables ¶
var ( DefaultAttributeTypes AttributeTypeCollection DefaultObjectClasses ObjectClassCollection DefaultLDAPSyntaxes LDAPSyntaxCollection DefaultMatchingRules MatchingRuleCollection )
Default Definition Collections
Functions ¶
func AttributeTypeUnmarshaler ¶
AttributeTypeUnmarshaler is a package-included function that honors the signature of the first class (closure) DefinitionUnmarshaler type.
The purpose of this function, and similar user-devised ones, is to unmarshal a definition with specific formatting included, such as linebreaks, leading specifier declarations and indenting.
func DITContentRuleUnmarshaler ¶
DITContentRuleUnmarshaler is a package-included function that honors the signature of the first class (closure) DefinitionUnmarshaler type.
The purpose of this function, and similar user-devised ones, is to unmarshal a definition with specific formatting included, such as linebreaks, leading specifier declarations and indenting.
func DITStructureRuleUnmarshaler ¶
DITStructureRuleUnmarshaler is a package-included function that honors the signature of the first class (closure) DefinitionUnmarshaler type.
The purpose of this function, and similar user-devised ones, is to unmarshal a definition with specific formatting included, such as linebreaks, leading specifier declarations and indenting.
func LDAPSyntaxUnmarshaler ¶
LDAPSyntaxUnmarshaler is a package-included function that honors the signature of the first class (closure) DefinitionUnmarshaler type.
The purpose of this function, and similar user-devised ones, is to unmarshal a definition with specific formatting included, such as linebreaks, leading specifier declarations and indenting.
func Marshal ¶
func Marshal(raw string, x any, atc AttributeTypeCollection, occ ObjectClassCollection, lsc LDAPSyntaxCollection, mrc MatchingRuleCollection, mruc MatchingRuleUseCollection, dcrc DITContentRuleCollection, dsrc DITStructureRuleCollection, nfc NameFormCollection) (err error)
Marshal takes the provided schema definition (def) and attempts to marshal it into x. x MUST be one of the following types:
• AttributeType
• ObjectClass
• LDAPSyntax
• MatchingRule
• MatchingRuleUse
• DITContentRule
• DITStructureRule
• NameForm
Should any validation errors occur, a non-nil instance of error is returned.
Note that it is far more convenient to use the Subschema.Marshal wrapper, as it only requires a single argument (the raw definition).
Example (NewAttributeType) ¶
lsc := PopulateDefaultLDAPSyntaxes() mrc := PopulateDefaultMatchingRules() def := `( 1.3.6.1.4.1.56521.999.104.17.2.1.10 NAME ( 'jessesNewAttr' 'jesseAltName' ) DESC 'This is an example AttributeType definition' OBSOLETE SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 EQUALITY caseIgnoreMatch X-ORIGIN 'Jesse Coretta' )` var x AttributeType err := Marshal(def, &x, nil, nil, lsc, mrc, nil, nil, nil, nil) if err != nil { panic(err) } fmt.Printf("%T is obsolete: %t\n", x, x.Obsolete)
Output: schemax.AttributeType is obsolete: true
Example (NewDITContentRule) ¶
atc := PopulateDefaultAttributeTypes() occ := PopulateDefaultObjectClasses() def := `( 2.16.840.1.113730.3.2.2 NAME 'inetOrgPerson-content-rule' AUX strongAuthenticationUser MUST uid MAY ( c $ l ) NOT telexNumber )` var x DITContentRule err := Marshal(def, &x, atc, occ, nil, nil, nil, nil, nil, nil) if err != nil { panic(err) } fmt.Printf("%T allows: %s\n", x, x.May)
Output: schemax.DITContentRule allows: ( c $ l )
Example (NewDITStructureRule) ¶
atc := PopulateDefaultAttributeTypes() occ := PopulateDefaultObjectClasses() nf := `( 1.3.6.1.4.1.56521.999.104.17.2.16.4 NAME 'jesseNameForm' DESC 'this is an example Name Form definition' OC account MUST ( cn $ o $ uid ) MAY ( description $ l ) X-ORIGIN 'Jesse Coretta' )` var z NameForm err := Marshal(nf, &z, atc, occ, nil, nil, nil, nil, nil, nil) if err != nil { panic(err) } nfc := NewNameForms() nfc.Set(&z) dsr := `( 0 NAME 'jesseDSR' DESC 'this is an example DIT Structure Rule' FORM jesseNameForm X-ORIGIN 'Jesse Coretta' )` var x DITStructureRule err = Marshal(dsr, &x, nil, nil, nil, nil, nil, nil, nil, nfc) if err != nil { panic(err) } fmt.Printf("%T NameForm: %s\n", x, x.Form.Name.Index(0))
Output: schemax.DITStructureRule NameForm: jesseNameForm
Example (NewLDAPSyntax) ¶
def := `( 1.3.6.1.4.1.56521.999.43.1.2.71 DESC 'This is an example LDAPSyntax definition' X-ORIGIN 'Jesse Coretta' )` var x LDAPSyntax err := Marshal(def, &x, nil, nil, nil, nil, nil, nil, nil, nil) if err != nil { panic(err) } fmt.Printf("%T OID: %s (%s)\n", x, x.OID, x.Description)
Output: schemax.LDAPSyntax OID: 1.3.6.1.4.1.56521.999.43.1.2.71 ('This is an example LDAPSyntax definition')
Example (NewMatchingRule) ¶
lsc := PopulateDefaultLDAPSyntaxes() def := `( 1.3.6.1.4.1.56521.999.314.21.1 NAME 'alternativeCaseIgnoreStringMatch' DESC 'This is an example MatchingRule definition' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Jesse Coretta' )` var x MatchingRule err := Marshal(def, &x, nil, nil, lsc, nil, nil, nil, nil, nil) if err != nil { panic(err) } fmt.Printf("%T syntax OID: %s\n", x, x.Syntax.OID)
Output: schemax.MatchingRule syntax OID: 1.3.6.1.4.1.1466.115.121.1.15
Example (NewNameForm) ¶
atc := PopulateDefaultAttributeTypes() occ := PopulateDefaultObjectClasses() nf := `( 1.3.6.1.4.1.56521.999.104.17.2.16.4 NAME 'jesseNameForm' DESC 'this is an example Name Form definition' OC account MUST ( cn $ o $ uid ) MAY ( description $ l ) X-ORIGIN 'Jesse Coretta' )` var z NameForm err := Marshal(nf, &z, atc, occ, nil, nil, nil, nil, nil, nil) if err != nil { panic(err) } fmt.Printf("%T requires: %s\n", z, z.Must)
Output: schemax.NameForm requires: ( cn $ o $ uid )
Example (NewObjectClass) ¶
atc := PopulateDefaultAttributeTypes() occ := PopulateDefaultObjectClasses() def := `( 1.3.6.1.4.1.56521.999.107.12.1.2.11 NAME ( 'testClass' ) DESC 'This is an example ObjectClass definition' STRUCTURAL MUST ( uid $ cn $ o ) MAY ( description $ l $ c ) X-ORIGIN 'Jesse Coretta' )` var x ObjectClass err := Marshal(def, &x, atc, occ, nil, nil, nil, nil, nil, nil) if err != nil { panic(err) } fmt.Printf("%T requires: %s\n", x, x.Must)
Output: schemax.ObjectClass requires: ( uid $ cn $ o )
func MatchingRuleUnmarshaler ¶
MatchingRuleUnmarshaler is a package-included function that honors the signature of the first class (closure) DefinitionUnmarshaler type.
The purpose of this function, and similar user-devised ones, is to unmarshal a definition with specific formatting included, such as linebreaks, leading specifier declarations and indenting.
func MatchingRuleUseUnmarshaler ¶
MatchingRuleUseUnmarshaler is a package-included function that honors the signature of the first class (closure) DefinitionUnmarshaler type.
The purpose of this function, and similar user-devised ones, is to unmarshal a definition with specific formatting included, such as linebreaks, leading specifier declarations and indenting.
func NameFormUnmarshaler ¶
NameFormUnmarshaler is a package-included function that honors the signature of the first class (closure) DefinitionUnmarshaler type.
The purpose of this function, and similar user-devised ones, is to unmarshal a definition with specific formatting included, such as linebreaks, leading specifier declarations and indenting.
func ObjectClassUnmarshaler ¶
ObjectClassUnmarshaler is a package-included function that honors the signature of the first class (closure) DefinitionUnmarshaler type.
The purpose of this function, and similar user-devised ones, is to unmarshal a definition with specific formatting included, such as linebreaks, leading specifier declarations and indenting.
func PopulateRFC2079AttributeTypes ¶
func PopulateRFC2079AttributeTypes( atc AttributeTypeCollection, lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC2079AttributeTypes only populates the provided AttributeTypes (atc) with AttributeType definitions defined in this RFC.
Definitions are imported from go-schemax/rfc2079.
Valid instances of LDAPSyntaxes (containing all referenced LDAPSyntax definitions) and MatchingRules (containing all referenced MatchingRules definitions), must be provided as the lsc and mrc arguments respectively.
func PopulateRFC2079ObjectClasses ¶
func PopulateRFC2079ObjectClasses( occ ObjectClassCollection, atc AttributeTypeCollection, lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC2079ObjectClasses only populates the provided ObjectClasses (occ) with ObjectClass definitions defined in this RFC.
Definitions are imported from go-schemax/rfc2079.
Valid instances of LDAPSyntaxes (containing all referenced LDAPSyntax definitions), MatchingRules (containing all referenced MatchingRules definitions), and AttributeTypes (containing all registered AttributeType definitions) must be provided as the atc, lsc and mrc arguments respectively.
func PopulateRFC2307AttributeTypes ¶
func PopulateRFC2307AttributeTypes( atc AttributeTypeCollection, lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC2307AttributeTypes only populates the provided AttributeTypes (atc) with AttributeType definitions defined in this RFC.
Definitions are imported from go-schemax/rfc2307.
Valid instances of LDAPSyntaxes (containing all referenced LDAPSyntax definitions) and MatchingRules (containing all referenced MatchingRules definitions), must be provided as the lsc and mrc arguments respectively.
func PopulateRFC2307MatchingRules ¶
func PopulateRFC2307MatchingRules(lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC2307MatchingRules only populates the provided MatchingRules (mrc) with MatchingRule definitions defined in this RFC (which is currently one (1) definition).
Definitions are imported from go-schemax/rfc2307.
A valid instance of LDAPSyntaxes that contains all referenced LDAPSyntax instances must be provided as the lsc argument.
func PopulateRFC2307ObjectClasses ¶
func PopulateRFC2307ObjectClasses( occ ObjectClassCollection, atc AttributeTypeCollection, lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC2307ObjectClasses only populates the provided ObjectClasses (occ) with ObjectClass definitions defined in this RFC.
Definitions are imported from go-schemax/rfc2307.
Valid instances of LDAPSyntaxes (containing all referenced LDAPSyntax definitions), MatchingRules (containing all referenced MatchingRules definitions), and AttributeTypes (containing all registered AttributeType definitions) must be provided as the atc, lsc and mrc arguments respectively.
func PopulateRFC2307Syntaxes ¶
func PopulateRFC2307Syntaxes(lsc LDAPSyntaxCollection)
PopulateRFC2307Syntaxes only populates the provided LDAPSyntaxes (lsc) with LDAPSyntax definitions defined in this RFC.
Definitions are imported from go-schemax/rfc2307.
func PopulateRFC2798AttributeTypes ¶
func PopulateRFC2798AttributeTypes( atc AttributeTypeCollection, lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC2798AttributeTypes only populates the provided AttributeTypes (atc) with AttributeType definitions defined in this RFC.
Definitions are imported from go-schemax/rfc2798.
Valid instances of LDAPSyntaxes (containing all referenced LDAPSyntax definitions) and MatchingRules (containing all referenced MatchingRules definitions), must be provided as the lsc and mrc arguments respectively.
func PopulateRFC2798ObjectClasses ¶
func PopulateRFC2798ObjectClasses( occ ObjectClassCollection, atc AttributeTypeCollection, lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC2798ObjectClasses only populates the provided ObjectClasses (occ) with ObjectClass definitions defined in this RFC.
Definitions are imported from go-schemax/rfc2798.
Valid instances of LDAPSyntaxes (containing all referenced LDAPSyntax definitions), MatchingRules (containing all referenced MatchingRules definitions), and AttributeTypes (containing all registered AttributeType definitions) must be provided as the atc, lsc and mrc arguments respectively.
func PopulateRFC3045AttributeTypes ¶ added in v1.1.6
func PopulateRFC3045AttributeTypes( atc AttributeTypeCollection, lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC3045AttributeTypes only populates the provided AttributeTypes (atc) with AttributeType definitions defined in this RFC.
Definitions are imported from go-schemax/rfc3045.
Valid instances of LDAPSyntaxes (containing all referenced LDAPSyntax definitions) and MatchingRules (containing all referenced MatchingRules definitions), must be provided as the lsc and mrc arguments respectively.
func PopulateRFC3672AttributeTypes ¶
func PopulateRFC3672AttributeTypes( atc AttributeTypeCollection, lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC3672AttributeTypes only populates the provided AttributeTypes (atc) with AttributeType definitions defined in this RFC.
Definitions are imported from go-schemax/rfc3672.
Valid instances of LDAPSyntaxes (containing all referenced LDAPSyntax definitions) and MatchingRules (containing all referenced MatchingRules definitions), must be provided as the lsc and mrc arguments respectively.
func PopulateRFC3672ObjectClasses ¶
func PopulateRFC3672ObjectClasses( occ ObjectClassCollection, atc AttributeTypeCollection, lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC3672ObjectClasses only populates the provided ObjectClasses (occ) with ObjectClass definitions defined in this RFC.
Definitions are imported from go-schemax/rfc3672.
Valid instances of LDAPSyntaxes (containing all referenced LDAPSyntax definitions), MatchingRules (containing all referenced MatchingRules definitions), and AttributeTypes (containing all registered AttributeType definitions) must be provided as the atc, lsc and mrc arguments respectively.
func PopulateRFC4512AttributeTypes ¶
func PopulateRFC4512AttributeTypes( atc AttributeTypeCollection, lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC4512AttributeTypes only populates the provided AttributeTypes (atc) with AttributeType definitions defined in this RFC.
Definitions are imported from go-schemax/rfc4512.
Valid instances of LDAPSyntaxes (containing all referenced LDAPSyntax definitions) and MatchingRules (containing all referenced MatchingRules definitions), must be provided as the lsc and mrc arguments respectively.
func PopulateRFC4512ObjectClasses ¶
func PopulateRFC4512ObjectClasses( occ ObjectClassCollection, atc AttributeTypeCollection, lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC4512ObjectClasses only populates the provided ObjectClasses (occ) with ObjectClass definitions defined in this RFC.
Definitions are imported from go-schemax/rfc4512.
Valid instances of LDAPSyntaxes (containing all referenced LDAPSyntax definitions), MatchingRules (containing all referenced MatchingRules definitions), and AttributeTypes (containing all registered AttributeType definitions) must be provided as the atc, lsc, and mrc arguments respectively.
func PopulateRFC4517MatchingRules ¶
func PopulateRFC4517MatchingRules(lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC4517MatchingRules only populates the provided MatchingRules (mrc) with MatchingRule definitions defined in this RFC.
Definitions are imported from go-schemax/rfc4517.
A valid instance of LDAPSyntaxes that contains all referenced LDAPSyntax instances must be provided as the lsc argument.
func PopulateRFC4517Syntaxes ¶
func PopulateRFC4517Syntaxes(lsc LDAPSyntaxCollection)
PopulateRFC4517Syntaxes only populates the provided LDAPSyntaxes (lsc) with LDAPSyntax definitions defined in this RFC.
Definitions are imported from go-schemax/rfc4517.
func PopulateRFC4519AttributeTypes ¶
func PopulateRFC4519AttributeTypes( atc AttributeTypeCollection, lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC4519AttributeTypes only populates the provided AttributeTypes (atc) with AttributeType definitions defined in this RFC.
Definitions are imported from go-schemax/rfc4519.
Valid instances of LDAPSyntaxes (containing all referenced LDAPSyntax definitions) and MatchingRules (containing all referenced MatchingRules definitions), must be provided as the lsc and mrc arguments respectively.
func PopulateRFC4519ObjectClasses ¶
func PopulateRFC4519ObjectClasses( occ ObjectClassCollection, atc AttributeTypeCollection, lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC4519ObjectClasses only populates the provided ObjectClasses (occ) with ObjectClass definitions defined in this RFC.
Definitions are imported from go-schemax/rfc4519.
Valid instances of LDAPSyntaxes (containing all referenced LDAPSyntax definitions), MatchingRules (containing all referenced MatchingRules definitions), and AttributeTypes (containing all registered AttributeType definitions) must be provided as the atc, lsc, and mrc arguments respectively.
func PopulateRFC4523AttributeTypes ¶
func PopulateRFC4523AttributeTypes( atc AttributeTypeCollection, lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC4523AttributeTypes only populates the provided AttributeTypes (atc) with AttributeType definitions defined in this RFC.
Definitions are imported from go-schemax/rfc4523.
Valid instances of LDAPSyntaxes (containing all referenced LDAPSyntax definitions) and MatchingRules (containing all referenced MatchingRules definitions), must be provided as the lsc and mrc arguments respectively.
func PopulateRFC4523MatchingRules ¶
func PopulateRFC4523MatchingRules(lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC4523MatchingRules only populates the provided MatchingRules (mrc) with MatchingRule definitions defined in this RFC.
Definitions are imported from go-schemax/rfc4523.
A valid instance of LDAPSyntaxes that contains all referenced LDAPSyntax instances must be provided as the lsc argument.
func PopulateRFC4523ObjectClasses ¶
func PopulateRFC4523ObjectClasses( occ ObjectClassCollection, atc AttributeTypeCollection, lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC4523ObjectClasses only populates the provided ObjectClasses (occ) with ObjectClass definitions defined in this RFC.
Definitions are imported from go-schemax/rfc4523.
Valid instances of LDAPSyntaxes (containing all referenced LDAPSyntax definitions), MatchingRules (containing all referenced MatchingRules definitions), and AttributeTypes (containing all registered AttributeType definitions) must be provided as the atc, lsc, and mrc arguments respectively.
func PopulateRFC4523Syntaxes ¶
func PopulateRFC4523Syntaxes(lsc LDAPSyntaxCollection)
PopulateRFC4523Syntaxes only populates the provided LDAPSyntaxes (lsc) with LDAPSyntax definitions defined in this RFC.
Definitions are imported from go-schemax/rfc4523.
func PopulateRFC4524AttributeTypes ¶
func PopulateRFC4524AttributeTypes( atc AttributeTypeCollection, lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC4524AttributeTypes only populates the provided AttributeTypes (atc) with AttributeType definitions defined in this RFC.
Definitions are imported from go-schemax/rfc4524.
Valid instances of LDAPSyntaxes (containing all referenced LDAPSyntax definitions) and MatchingRules (containing all referenced MatchingRules definitions), must be provided as the lsc and mrc arguments respectively.
func PopulateRFC4524ObjectClasses ¶
func PopulateRFC4524ObjectClasses( occ ObjectClassCollection, atc AttributeTypeCollection, lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC4524ObjectClasses only populates the provided ObjectClasses (occ) with ObjectClass definitions defined in this RFC.
Definitions are imported from go-schemax/rfc4524.
Valid instances of LDAPSyntaxes (containing all referenced LDAPSyntax definitions), MatchingRules (containing all referenced MatchingRules definitions), and AttributeTypes (containing all registered AttributeType definitions) must be provided as the atc, lsc and mrc arguments respectively.
func PopulateRFC4530AttributeTypes ¶
func PopulateRFC4530AttributeTypes( atc AttributeTypeCollection, lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC4530AttributeTypes only populates the provided AttributeTypes (atc) with AttributeType definitions defined in this RFC.
Definitions are imported from go-schemax/rfc4530.
Valid instances of LDAPSyntaxes (containing all referenced LDAPSyntax definitions) and MatchingRules (containing all referenced MatchingRules definitions), must be provided as the lsc and mrc arguments respectively.
func PopulateRFC4530MatchingRules ¶
func PopulateRFC4530MatchingRules(lsc LDAPSyntaxCollection, mrc MatchingRuleCollection)
PopulateRFC4530MatchingRules only populates the provided MatchingRules (mrc) with MatchingRule definitions defined in this RFC.
Definitions are imported from go-schemax/rfc4530.
A valid instance of LDAPSyntaxes that contains all referenced LDAPSyntax instances must be provided as the lsc argument.
func PopulateRFC4530Syntaxes ¶
func PopulateRFC4530Syntaxes(lsc LDAPSyntaxCollection)
PopulateRFC4530Syntaxes only populates the provided LDAPSyntaxes (lsc) with LDAPSyntax definitions defined in this RFC.
Definitions are imported from go-schemax/rfc4530.
func Unmarshal ¶
Unmarshal takes an instance of one (1) of the following types and (if valid) and returns the textual form of the definition:
• ObjectClass
• AttributeType
• LDAPSyntax
• MatchingRule
• MatchingRuleUse
• DITContentRule
• DITStructureRule
• NameForm
Should any validation errors occur, a non-nil instance of error is returned.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() name := sch.ATC.Get(`name`) def, err := Unmarshal(name) if err != nil { panic(err) } fmt.Printf("%s\n", def)
Output: ( 2.5.4.41 NAME 'name' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'RFC4519' )
Types ¶
type ApplicableAttributeTypes ¶
type ApplicableAttributeTypes struct {
*AttributeTypes
}
ApplicableAttributeTypes contains an embedded instance of *AttributeTypes. This alias type reflects the APPLIES field of a matchingRuleUse definition.
func (ApplicableAttributeTypes) Label ¶
func (r ApplicableAttributeTypes) Label() string
Label returns the known label for the receiver, if one exists.
Example ¶
aps := ApplicableAttributeTypes{} lab := aps.Label() fmt.Printf("%T label: %s (len:%d)\n", aps, lab, len(lab))
Output: schemax.ApplicableAttributeTypes label: APPLIES (len:7)
func (ApplicableAttributeTypes) String ¶
func (r ApplicableAttributeTypes) String() string
String returns a properly-delimited sequence of string values, either as a Name or OID, for the receiver type.
type AttributeType ¶
type AttributeType struct { OID OID Name Name Description Description Obsolete bool SuperType SuperiorAttributeType Equality Equality Ordering Ordering Substring Substring Syntax *LDAPSyntax Usage Usage Extensions *Extensions // contains filtered or unexported fields }
AttributeType conforms to the specifications of RFC4512 Section 4.1.2.
Example (ManualComposition) ¶
// This example demonstrates an ALTERNATIVE to // raw definition parsing, instead allowing any // given definition to be created from scratch // in a more object oriented fashion. // First, create a minimal subschema just to lookup // dependencies such as an LDAPSyntax or Matching // Rule. Skip if you've already got your own subschema // instance to use. sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() mr := sch.GetMatchingRule(`caseIgnoreMatch`) syn := sch.GetLDAPSyntax(`1.3.6.1.4.1.1466.115.121.1.15`) // Make sure we got both of the above // dependency components. if mr.IsZero() || syn.IsZero() { // handle your fatal error ... } // Brand our matching rule as // an EQUALITY matching rule. eq := Equality{mr} // Create a new instance of *AttributeType // and populate as needed. def := NewAttributeType() def.OID = NewOID(`1.3.6.1.4.1.56521.999.1.2.3.1`) def.Name = NewName(`genericExampleAttribute`, `attrAltName`) def.Syntax = syn def.Equality = eq def.Description = Description(`Generic example attribute`) def.SetSingleValue() // Make sure validation checks return NO // errors before using your definition! if err := def.Validate(); err != nil { // handle your fatal error } // All checks pass! Use your new definition as needed!
Output:
func NewAttributeType ¶ added in v1.1.0
func NewAttributeType() *AttributeType
NewAttributeType returns a newly initialized, yet effectively nil, instance of *AttributeType.
Users generally do not need to execute this function unless an instance of the returned type will be manually populated (as opposed to parsing a raw text definition).
func (*AttributeType) Collective ¶
func (r *AttributeType) Collective() bool
Collective returns a boolean value indicative of whether the receiver describes a COLLECTIVE attribute type.
func (*AttributeType) Equal ¶
func (r *AttributeType) Equal(x any) (eq bool)
Equal performs a deep-equal between the receiver and the provided definition type.
Description text is ignored.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() at1 := &AttributeType{ Name: NewName(`fakeName`), OID: NewOID(`1.3.6.1.4.1.56521.999.104.17.2.1.55`), Syntax: sch.LSC.Get(`1.3.6.1.4.1.1466.115.121.1.15`), } at2 := &AttributeType{ Name: NewName(`fakeName`), OID: NewOID(`1.3.6.1.4.1.56521.999.104.17.2.1.55`), Syntax: sch.LSC.Get(`1.3.6.1.4.1.1466.115.121.1.15`), } fmt.Printf("at1 is equal to at2: %t\n", at1.Equal(at2))
Output: at1 is equal to at2: true
func (*AttributeType) HumanReadable ¶
func (r *AttributeType) HumanReadable() bool
HumanReadable is a convenience wrapper for Extensions.HumanReadable(), which returns a boolean value indicative of human readability. If super typing is in effect, an attempt to determine human readability by recursive inheritance is made. Failing this, if the receiver is assigned an *LDAPSyntax value, it is evaluated similarly. A fallback of true is returned as a last recourse.
func (*AttributeType) Info ¶
func (r *AttributeType) Info() []byte
Info returns the assigned informational byte slice instance stored within the receiver.
func (*AttributeType) IsZero ¶
func (r *AttributeType) IsZero() bool
IsZero returns a boolean value indicative of whether the receiver is considered empty or uninitialized.
Example ¶
at := &AttributeType{} fmt.Printf("%T is zero: %t\n", at, at.IsZero()) // Output *schemax.AttributeType is zero: true
Output:
func (*AttributeType) Map ¶
func (r *AttributeType) Map() (def map[string][]string)
Map is a convenience method that returns a map[string][]string instance containing the effective contents of the receiver.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = NewAttributeTypes() myDef := `( 1.3.6.1.4.1.56521.999.104.17.2.1.10 NAME ( 'jessesNewAttr' 'jesseAltName' ) DESC 'This is an example AttributeType definition' SINGLE-VALUE SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{64} EQUALITY caseIgnoreMatch X-ORIGIN 'Jesse Coretta' )` if err := sch.MarshalAttributeType(myDef); err != nil { panic(err) } jattr := sch.ATC.Get(`jessesNewAttr`).Map() fmt.Printf("%T fields: %d\n", jattr, len(jattr))
Output: map[string][]string fields: 10
func (*AttributeType) MaxLength ¶
func (r *AttributeType) MaxLength() int
MaxLength returns the integer value, if one was specified, that defines the maximum acceptable value size supported by this *AttributeType per its associated *LDAPSyntax. If not applicable, a 0 is returned.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() at := &AttributeType{ Name: NewName(`fakeName`), OID: NewOID(`1.3.6.1.4.1.56521.999.104.17.2.1.55`), Syntax: sch.LSC.Get(`1.3.6.1.4.1.1466.115.121.1.15`), } at.SetMaxLength(128) fmt.Printf("Max allowed length for %T value: %d\n", at, at.MaxLength())
Output: Max allowed length for *schemax.AttributeType value: 128
func (*AttributeType) NoUserModification ¶
func (r *AttributeType) NoUserModification() bool
NoUserModification returns a boolean value indicative of whether the receiver describes a NO-USER-MODIFICATION attribute type.
func (*AttributeType) SetCollective ¶
func (r *AttributeType) SetCollective()
SetCollective marks the receiver as COLLECTIVE.
func (*AttributeType) SetInfo ¶
func (r *AttributeType) SetInfo(info []byte)
SetInfo assigns the byte slice to the receiver. This is a user-leveraged field intended to allow arbitrary information (documentation?) to be assigned to the definition.
func (*AttributeType) SetMaxLength ¶
func (r *AttributeType) SetMaxLength(max int)
SetMaxLength sets the minimum upper bounds, or maximum length, of the receiver instance. The argument must be a positive, non-zero integer.
This will only apply to *AttributeTypes that use a human-readable syntax.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() at := &AttributeType{ Name: NewName(`fakeName`), OID: NewOID(`1.3.6.1.4.1.56521.999.104.17.2.1.55`), Syntax: sch.LSC.Get(`1.3.6.1.4.1.1466.115.121.1.15`), } at.SetMaxLength(128) fmt.Printf("Max allowed length for %T value: %d\n", at, at.MaxLength())
Output: Max allowed length for *schemax.AttributeType value: 128
func (*AttributeType) SetNoUserModification ¶
func (r *AttributeType) SetNoUserModification()
SetCollective marks the receiver as NO-USER-MODIFICATION.
func (*AttributeType) SetSingleValue ¶
func (r *AttributeType) SetSingleValue()
SetSingleValue marks the receiver as SINGLE-VALUE.
func (*AttributeType) SetSpecifier ¶
func (r *AttributeType) SetSpecifier(spec string)
SetSpecifier assigns a string value to the receiver, useful for placement into configurations that require a type name (e.g.: attributetype). This will be displayed at the beginning of the definition value during the unmarshal or unsafe stringification process.
func (*AttributeType) SetUnmarshaler ¶
func (r *AttributeType) SetUnmarshaler(fn DefinitionUnmarshaler)
SetUnmarshaler assigns the provided DefinitionUnmarshaler signature value to the receiver. The provided function shall be executed during the unmarshal or unsafe stringification process.
func (*AttributeType) SingleValue ¶
func (r *AttributeType) SingleValue() bool
SingleValue returns a boolean value indicative of whether the receiver describes a SINGLE-VALUE attribute type.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = NewAttributeTypes() myDef := `( 1.3.6.1.4.1.56521.999.104.17.2.1.10 NAME ( 'jessesNewAttr' 'jesseAltName' ) DESC 'This is an example AttributeType definition' SINGLE-VALUE SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 EQUALITY caseIgnoreMatch X-ORIGIN 'Jesse Coretta' )` if err := sch.MarshalAttributeType(myDef); err != nil { panic(err) } jattr := sch.ATC.Get(`jessesNewAttr`) fmt.Printf("%T is single-value: %t\n", jattr, jattr.SingleValue())
Output: *schemax.AttributeType is single-value: true
func (*AttributeType) String ¶
func (r *AttributeType) String() (def string)
String is an unsafe convenience wrapper for Unmarshal(r). If an error is encountered, an empty string definition is returned. If reliability and error handling are important, use Unmarshal.
func (*AttributeType) Type ¶
func (r *AttributeType) Type() string
Type returns the formal name of the receiver in order to satisfy signature requirements of the Definition interface type.
func (*AttributeType) Validate ¶
func (r *AttributeType) Validate() (err error)
Validate returns an error that reflects any fatal condition observed regarding the receiver configuration.
type AttributeTypeCollection ¶
type AttributeTypeCollection interface { // Get returns the *AttributeType instance retrieved as a result // of a term search, based on Name or OID. If no match is found, // nil is returned. Get(any) *AttributeType // Index returns the *AttributeType instance stored at the nth // index within the receiver, or nil. Index(int) *AttributeType // Equal performs a deep-equal between the receiver and the // interface AttributeTypeCollection provided. Equal(AttributeTypeCollection) bool // Set returns an error instance based on an attempt to add // the provided *AttributeType instance to the receiver. Set(*AttributeType) error // Contains returns the index number and presence boolean that // reflects the result of a term search within the receiver. Contains(any) (int, bool) // String returns a properly-delimited sequence of string // values, either as a Name or OID, for the receiver type. String() string // Label returns the field name associated with the interface // types, or a zero string if no label is appropriate. Label() string // IsZero returns a boolean value indicative of whether the // receiver is considered zero, or undefined. IsZero() bool // Len returns an integer value indicative of the current // number of elements stored within the receiver. Len() int // SetSpecifier assigns a string value to all definitions within // the receiver. This value is used in cases where a definition // type name (e.g.: attributetype, objectclass, etc.) is required. // This value will be displayed at the beginning of the definition // value during the unmarshal or unsafe stringification process. SetSpecifier(string) // SetUnmarshaler assigns the provided DefinitionUnmarshaler // signature to all definitions within the receiver. The provided // function shall be executed during the unmarshal or unsafe // stringification process. SetUnmarshaler(DefinitionUnmarshaler) }
AttributeTypeCollection describes all of the following types:
• AttributeTypes
• RequiredAttributeTypes
• PermittedAttributeTypes
• ProhibitedAttributeTypes
• ApplicableAttributeTypes
func NewApplicableAttributeTypes ¶
func NewApplicableAttributeTypes() AttributeTypeCollection
NewApplicableAttributeTypes initializes an embedded instance of *AttributeTypes within the return value.
Example ¶
aps := NewApplicableAttributeTypes() fmt.Printf("%T is zero: %t\n", aps, aps.IsZero())
Output: *schemax.ApplicableAttributeTypes is zero: true
func NewAttributeTypes ¶
func NewAttributeTypes() AttributeTypeCollection
NewAttributeTypes initializes and returns a new AttributeTypeCollection interface object.
Example ¶
atm := NewAttributeTypes() fmt.Printf("%T is zero: %t", atm, atm.IsZero())
Output: *schemax.AttributeTypes is zero: true
func NewPermittedAttributeTypes ¶
func NewPermittedAttributeTypes() AttributeTypeCollection
NewPermittedAttributeTypes initializes an embedded instance of *AttributeTypes within the return value.
Example ¶
pats := NewPermittedAttributeTypes() fmt.Printf("%T is zero: %t\n", pats, pats.IsZero())
Output: *schemax.PermittedAttributeTypes is zero: true
func NewProhibitedAttributeTypes ¶
func NewProhibitedAttributeTypes() AttributeTypeCollection
NewProhibitedAttributeTypes initializes an embedded instance of *AttributeTypes within the return value.
Example ¶
pats := NewProhibitedAttributeTypes() fmt.Printf("%T is zero: %t\n", pats, pats.IsZero())
Output: *schemax.ProhibitedAttributeTypes is zero: true
func NewRequiredAttributeTypes ¶
func NewRequiredAttributeTypes() AttributeTypeCollection
NewRequiredAttributeTypes initializes an embedded instance of *AttributeTypes within the return value.
Example ¶
reqs := NewRequiredAttributeTypes() fmt.Printf("%T is zero: %t\n", reqs, reqs.IsZero())
Output: *schemax.RequiredAttributeTypes is zero: true
func PopulateDefaultAttributeTypes ¶
func PopulateDefaultAttributeTypes() (atc AttributeTypeCollection)
PopulateDefaultAttributeTypes returns a new auto-populated instance of AttributeTypes. Within this structure are all of the following:
• Attribute types from RFC2079 (imported from go-schemax/rfc2079)
• Attribute types from RFC2307 (imported from go-schemax/rfc2307)
• Attribute types from RFC2798 (imported from go-schemax/rfc2798)
• Attribute types from RFC3045 (imported from go-schemax/rfc3045)
• Attribute types from RFC4512 (imported from go-schemax/rfc4512)
• Attribute types from RFC4519 (imported from go-schemax/rfc4519)
• Attribute types from RFC4523 (imported from go-schemax/rfc4523)
• Attribute types from RFC4524 (imported from go-schemax/rfc4524)
• Attribute types from RFC4530 (imported from go-schemax/rfc4530)
• Attribute types from RFC3672 (imported from go-schemax/rfc3672)
Example ¶
atm := NewAttributeTypes() fmt.Printf("%T is zero: %t", atm, atm.IsZero())
Output: *schemax.AttributeTypes is zero: true
type AttributeTypes ¶
type AttributeTypes struct {
// contains filtered or unexported fields
}
AttributeTypes is a thread-safe collection of *AttributeType slice instances.
func (*AttributeTypes) Contains ¶
func (r *AttributeTypes) Contains(x any) (int, bool)
Contains is a thread-safe method that returns a collection slice element index integer and a presence-indicative boolean value based on a term search conducted within the receiver.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() _, exists := sch.ATC.Contains(`name`) fmt.Printf("name AttributeType exists: %t\n", exists)
Output: name AttributeType exists: true
func (*AttributeTypes) Equal ¶
func (r *AttributeTypes) Equal(x AttributeTypeCollection) bool
Equal performs a deep-equal between the receiver and the provided collection type.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() otherATC := NewAttributeTypes() same := sch.ATC.Equal(otherATC) fmt.Printf("%T instances are equal: %t\n", sch.ATC, same)
Output: *schemax.AttributeTypes instances are equal: false
func (*AttributeTypes) Get ¶
func (r *AttributeTypes) Get(x any) *AttributeType
Get combines Contains and Index method executions to return an entry based on a term search conducted within the receiver.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() if attr := sch.ATC.Get(`name`); !attr.IsZero() { fmt.Printf("Name OID: %s\n", attr.OID) }
Output: Name OID: 2.5.4.41
func (*AttributeTypes) Index ¶
func (r *AttributeTypes) Index(idx int) *AttributeType
Index is a thread-safe method that returns the nth collection slice element if defined, else nil. This method supports use of negative indices which should be used with special care.
func (*AttributeTypes) IsZero ¶
func (r *AttributeTypes) IsZero() bool
IsZero returns a boolean value indicative of whether the receiver is considered empty or uninitialized.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() isZero := sch.ATC.IsZero() fmt.Printf("%T is zero: %t\n", sch.ATC, isZero)
Output: *schemax.AttributeTypes is zero: false
func (AttributeTypes) Label ¶
func (r AttributeTypes) Label() string
Label returns the known label for the receiver, if one exists.
func (AttributeTypes) Len ¶
func (r AttributeTypes) Len() int
Len is a thread-safe method that returns the effective length of the receiver slice collection.
func (*AttributeTypes) Set ¶
func (r *AttributeTypes) Set(x *AttributeType) error
Set is a thread-safe append method that returns an error instance indicative of whether the append operation failed in some manner. Uniqueness is enforced for new elements based on Object Identifier and not the effective Name of the definition, if defined.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() sch.ATC.Set(&AttributeType{ Name: NewName(`fakeName`), OID: NewOID(`1.3.6.1.4.1.56521.999.104.17.2.1.55`), Syntax: sch.LSC.Get(`1.3.6.1.4.1.1466.115.121.1.15`), }) if get := sch.ATC.Get(`fakeName`); !get.IsZero() { fmt.Printf("fakeName OID: %s\n", get.OID) }
Output: fakeName OID: 1.3.6.1.4.1.56521.999.104.17.2.1.55
func (*AttributeTypes) SetMacros ¶
func (r *AttributeTypes) SetMacros(macros *Macros)
SetMacros assigns the *Macros instance to the receiver, allowing subsequent OID resolution capabilities during the addition of new slice elements.
func (*AttributeTypes) SetSpecifier ¶
func (r *AttributeTypes) SetSpecifier(spec string)
SetSpecifier is a convenience method that executes the SetSpecifier method in iterative fashion for all definitions within the receiver.
func (*AttributeTypes) SetUnmarshaler ¶
func (r *AttributeTypes) SetUnmarshaler(fn DefinitionUnmarshaler)
SetUnmarshaler is a convenience method that executes the SetUnmarshaler method in iterative fashion for all definitions within the receiver.
func (*AttributeTypes) String ¶
func (r *AttributeTypes) String() string
String is a non-functional stringer method needed to satisfy interface type requirements and should not be used. See the String() method for ApplicableAttributeTypes, RequiredAttributeTypes, PermittedAttributeTypes and ProhibitedAttributeTypes instead.
type AuxiliaryObjectClasses ¶
type AuxiliaryObjectClasses struct {
*ObjectClasses
}
AuxiliaryObjectClasses contains an embedded *ObjectClasses instance. This type alias is meant to reside within the AUX field of a dITContentRule definition.
func (AuxiliaryObjectClasses) Label ¶
func (r AuxiliaryObjectClasses) Label() string
Label returns the known label for the receiver, if one exists.
Example ¶
aux := AuxiliaryObjectClasses{} lab := aux.Label() fmt.Printf("%T label: %s (len:%d)\n", aux, lab, len(lab))
Output: schemax.AuxiliaryObjectClasses label: AUX (len:3)
func (AuxiliaryObjectClasses) String ¶
func (r AuxiliaryObjectClasses) String() string
String returns a properly-delimited sequence of string values, either as a Name or OID, for the receiver type.
type DITContentRule ¶
type DITContentRule struct { OID OID Name Name Description Description Obsolete bool Aux ObjectClassCollection Must AttributeTypeCollection May AttributeTypeCollection Not AttributeTypeCollection Extensions *Extensions // contains filtered or unexported fields }
DITContentRule conforms to the specifications of RFC4512 Section 4.1.6.
The OID value of this type MUST match the OID of a known (and catalogued) STRUCTURAL *ObjectClass instance.
Example (ManualComposition) ¶
// This example demonstrates an ALTERNATIVE to // raw definition parsing, instead allowing any // given definition to be created from scratch // in a more object oriented fashion. // First, create a minimal subschema just to lookup // ObjectClass or AttributeType instance required, // permitted or forbidden by a given DITContentRule. // Skip if you've already got your own subschema // instance to use. sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() sch.OCC = PopulateDefaultObjectClasses() // Create a new instance of *DITContentRule // and populate as needed. def := NewDITContentRule() // The OID MUST match the OID of the STRUCTURAL // objectClass assigned to entries intended for // governing by this rule! This example uses // the 'account' objectClass OID from RFC4524: def.OID = NewOID(`0.9.2342.19200300.100.4.5`) def.Name = NewName(`genericExampleRule`, `ruleAltName`) def.Description = Description(`Generic example content rule`) // Direct our new class to mandate the use of cn, o and mail // attribute types. Alter as needed. for _, must := range []string{`cn`, `o`, `mail`} { if at := sch.GetAttributeType(must); !at.IsZero() { def.Must.Set(at) } } // Direct our new class to allow the OPTIONAL use of c, description // givenName and sn attribute types. Alter as needed. for _, may := range []string{`c`, `description`, `givenName`, `sn`} { if at := sch.GetAttributeType(may); !at.IsZero() { def.May.Set(at) } } // Direct our new class to DISALLOW the use of c, description // givenName and sn attribute types. Alter as needed. for _, not := range []string{`co`, `l`} { if at := sch.GetAttributeType(not); !at.IsZero() { def.Not.Set(at) } } // Direct our new rule to allow the use of specific auxiliary // objectClasses. Alter as needed. for _, aux := range []string{`posixAccount`, `shadowAccount`} { if at := sch.GetObjectClass(aux); !at.IsZero() { def.Aux.Set(at) } } // Make sure validation checks return NO // errors before using your definition! if err := def.Validate(); err != nil { // handle your fatal error } // All checks pass! Use your new definition as needed!
Output:
func NewDITContentRule ¶ added in v1.1.0
func NewDITContentRule() *DITContentRule
NewDITContentRule returns a newly initialized, yet effectively nil, instance of *DITContentRule.
Users generally do not need to execute this function unless an instance of the returned type will be manually populated (as opposed to parsing a raw text definition).
func (*DITContentRule) Belongs ¶
func (r *DITContentRule) Belongs(aux *ObjectClass) (belongs bool)
Belongs returns a boolean value indicative of whether the provided AUXILIARY *ObjectClass belongs to the receiver instance of *DITContentRule.
func (*DITContentRule) Equal ¶
func (r *DITContentRule) Equal(x any) (eq bool)
Equal performs a deep-equal between the receiver and the provided definition type.
Description text is ignored.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() sch.OCC = PopulateDefaultObjectClasses() sch.DCRC = NewDITContentRules() posixAcct := sch.OCC.Get(`posixAccount`) shadowAcct := sch.OCC.Get(`posixAccount`) uidAttr := sch.ATC.Get(`uid`) descAttr := sch.ATC.Get(`description`) givenNameAttr := sch.ATC.Get(`givenName`) if posixAcct.IsZero() || shadowAcct.IsZero() { panic("missing key ObjectClasse instances") } if uidAttr.IsZero() || descAttr.IsZero() || givenNameAttr.IsZero() { panic("missing key AttributeType instances") } aux := NewAuxiliaryObjectClasses() aux.Set(posixAcct) aux.Set(shadowAcct) must := NewRequiredAttributeTypes() must.Set(uidAttr) may := NewPermittedAttributeTypes() may.Set(descAttr) not := NewProhibitedAttributeTypes() not.Set(givenNameAttr) dcr1 := &DITContentRule{ OID: NewOID(`0.9.2342.19200300.100.4.5`), Name: NewName(`jesseAccountContentRule`), Aux: aux, Must: must, May: may, Not: not, } dcr2 := &DITContentRule{ OID: NewOID(`0.9.2342.19200300.100.4.5`), Name: NewName(`jesseAccountContentRule2`), Aux: aux, Must: must, May: may, Not: not, } same := dcr1.Equal(dcr2) fmt.Printf("The two %T instances are equal: %t\n", dcr1, same)
Output: The two *schemax.DITContentRule instances are equal: false
func (*DITContentRule) Info ¶
func (r *DITContentRule) Info() []byte
Info returns the assigned informational byte slice instance stored within the receiver.
func (*DITContentRule) IsZero ¶
func (r *DITContentRule) IsZero() bool
IsZero returns a boolean value indicative of whether the receiver is considered empty or uninitialized.
Example ¶
dcr := &DITContentRule{} fmt.Printf("%T is zero: %t\n", dcr, dcr.IsZero()) // Output *schemax.DITContentRule is zero: true
Output:
func (*DITContentRule) Map ¶
func (r *DITContentRule) Map() (def map[string][]string)
Map is a convenience method that returns a map[string][]string instance containing the effective contents of the receiver.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() sch.OCC = PopulateDefaultObjectClasses() myDef := `( 2.16.840.1.113730.3.2.2 NAME 'inetOrgPerson-content-rule' AUX strongAuthenticationUser MUST uid MAY c NOT telexNumber )` if err := sch.MarshalDITContentRule(myDef); err != nil { panic(err) } dcr := sch.DCRC.Get(`2.16.840.1.113730.3.2.2`).Map() fmt.Printf("%T fields: %d\n", dcr, len(dcr))
Output: map[string][]string fields: 8
func (*DITContentRule) Permits ¶
func (r *DITContentRule) Permits(x any) (permitted bool)
Permits returns a boolean value indicative of whether the provided value is allowed from use per the receiver.
func (*DITContentRule) Prohibits ¶
func (r *DITContentRule) Prohibits(x any) (prohibited bool)
Prohibits returns a boolean value indicative of whether the provided value is prohibited from use per the receiver.
func (*DITContentRule) Requires ¶
func (r *DITContentRule) Requires(x any) (required bool)
Requires returns a boolean value indicative of whether the provided value is required per the receiver.
func (*DITContentRule) SetInfo ¶
func (r *DITContentRule) SetInfo(info []byte)
SetInfo assigns the byte slice to the receiver. This is a user-leveraged field intended to allow arbitrary information (documentation?) to be assigned to the definition.
func (*DITContentRule) SetSpecifier ¶
func (r *DITContentRule) SetSpecifier(spec string)
SetSpecifier assigns a string value to the receiver, useful for placement into configurations that require a type name (e.g.: ditcontentrule). This will be displayed at the beginning of the definition value during the unmarshal or unsafe stringification process.
func (*DITContentRule) SetUnmarshaler ¶
func (r *DITContentRule) SetUnmarshaler(fn DefinitionUnmarshaler)
SetUnmarshaler assigns the provided DefinitionUnmarshaler signature value to the receiver. The provided function shall be executed during the unmarshal or unsafe stringification process.
func (DITContentRule) String ¶
func (r DITContentRule) String() (def string)
String is an unsafe convenience wrapper for Unmarshal(r). If an error is encountered, an empty string definition is returned. If reliability and error handling are important, use Unmarshal.
func (*DITContentRule) Type ¶
func (r *DITContentRule) Type() string
Type returns the formal name of the receiver in order to satisfy signature requirements of the Definition interface type.
func (*DITContentRule) Validate ¶
func (r *DITContentRule) Validate() (err error)
Validate returns an error that reflects any fatal condition observed regarding the receiver configuration.
type DITContentRuleCollection ¶
type DITContentRuleCollection interface { // Get returns the *DITContentRule instance retrieved as a result // of a term search, based on Name or OID. If no match is found, // nil is returned. Get(any) *DITContentRule // Index returns the *DITContentRule instance stored at the nth // index within the receiver, or nil. Index(int) *DITContentRule // Equal performs a deep-equal between the receiver and the // interface DITContentRuleCollection provided. Equal(DITContentRuleCollection) bool // Set returns an error instance based on an attempt to add // the provided *DITContentRule instance to the receiver. Set(*DITContentRule) error // Contains returns the index number and presence boolean that // reflects the result of a term search within the receiver. Contains(any) (int, bool) // String returns a properly-delimited sequence of string // values, either as a Name or OID, for the receiver type. String() string // Label returns the field name associated with the interface // types, or a zero string if no label is appropriate. Label() string // IsZero returns a boolean value indicative of whether the // receiver is considered zero, or undefined. IsZero() bool // Len returns an integer value indicative of the current // number of elements stored within the receiver. Len() int // SetSpecifier assigns a string value to all definitions within // the receiver. This value is used in cases where a definition // type name (e.g.: attributetype, objectclass, etc.) is required. // This value will be displayed at the beginning of the definition // value during the unmarshal or unsafe stringification process. SetSpecifier(string) // SetUnmarshaler assigns the provided DefinitionUnmarshaler // signature to all definitions within the receiver. The provided // function shall be executed during the unmarshal or unsafe // stringification process. SetUnmarshaler(DefinitionUnmarshaler) }
DITContentRuleCollection describes all DITContentRules-based types.
func NewDITContentRules ¶
func NewDITContentRules() DITContentRuleCollection
NewDITContentRules initializes and returns a new DITContentRuleCollection interface object.
Example ¶
dcrm := NewDITContentRules() fmt.Printf("%T is zero: %t\n", dcrm, dcrm.IsZero())
Output: *schemax.DITContentRules is zero: true
type DITContentRules ¶
type DITContentRules struct {
// contains filtered or unexported fields
}
DITContentRules is a thread-safe collection of *DITContentRule slice instances.
func (DITContentRules) Contains ¶
func (r DITContentRules) Contains(x any) (int, bool)
Contains is a thread-safe method that returns a collection slice element index integer and a presence-indicative boolean value based on a term search conducted within the receiver.
Example ¶
sch := NewSubschema() dcr := &DITContentRule{} _, found := sch.DCRC.Contains(dcr) fmt.Printf("%T exists within %T: %t\n", dcr, sch.DCRC, found)
Output: *schemax.DITContentRule exists within *schemax.DITContentRules: false
func (DITContentRules) Equal ¶
func (r DITContentRules) Equal(x DITContentRuleCollection) bool
Equal performs a deep-equal between the receiver and the provided collection type.
Example ¶
dcrm1 := NewDITContentRules() dcrm2 := NewDITContentRules() fmt.Printf("%T instances are equal: %t\n", dcrm1, dcrm1.Equal(dcrm2))
Output: *schemax.DITContentRules instances are equal: true
func (DITContentRules) Get ¶
func (r DITContentRules) Get(x any) *DITContentRule
Get combines Contains and Index method executions to return an entry based on a term search conducted within the receiver.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() sch.OCC = PopulateDefaultObjectClasses() sch.DCRC = NewDITContentRules() posixAcct := sch.OCC.Get(`posixAccount`) shadowAcct := sch.OCC.Get(`posixAccount`) uidAttr := sch.ATC.Get(`uid`) descAttr := sch.ATC.Get(`description`) givenNameAttr := sch.ATC.Get(`givenName`) if posixAcct.IsZero() || shadowAcct.IsZero() { panic("missing key ObjectClasse instances") } if uidAttr.IsZero() || descAttr.IsZero() || givenNameAttr.IsZero() { panic("missing key AttributeType instances") } aux := NewAuxiliaryObjectClasses() aux.Set(posixAcct) aux.Set(shadowAcct) must := NewRequiredAttributeTypes() must.Set(uidAttr) may := NewPermittedAttributeTypes() may.Set(descAttr) not := NewProhibitedAttributeTypes() not.Set(givenNameAttr) sch.DCRC.Set(&DITContentRule{ OID: NewOID(`0.9.2342.19200300.100.4.5`), Name: NewName(`jesseAccountContentRule`), Aux: aux, Must: must, May: may, Not: not, }) dcr := sch.DCRC.Get(`jesseAccountContentRule`) fmt.Printf("%T.Name: %s\n", *dcr, dcr.Name.Index(0))
Output: schemax.DITContentRule.Name: jesseAccountContentRule
func (DITContentRules) Index ¶
func (r DITContentRules) Index(idx int) *DITContentRule
Index is a thread-safe method that returns the nth collection slice element if defined, else nil. This method supports use of negative indices which should be used with special care.
func (DITContentRules) IsZero ¶
func (r DITContentRules) IsZero() bool
IsZero returns a boolean value indicative of whether the receiver is considered empty or uninitialized.
func (DITContentRules) Label ¶
func (r DITContentRules) Label() string
Label returns the known label for the receiver, if one exists.
func (DITContentRules) Len ¶
func (r DITContentRules) Len() int
Len is a thread-safe method that returns the effective length of the receiver slice collection.
func (*DITContentRules) Set ¶
func (r *DITContentRules) Set(x *DITContentRule) error
Set is a thread-safe append method that returns an error instance indicative of whether the append operation failed in some manner. Uniqueness is enforced for new elements based on Object Identifier and not the effective Name of the definition, if defined.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() sch.OCC = PopulateDefaultObjectClasses() sch.DCRC = NewDITContentRules() posixAcct := sch.OCC.Get(`posixAccount`) shadowAcct := sch.OCC.Get(`posixAccount`) uidAttr := sch.ATC.Get(`uid`) descAttr := sch.ATC.Get(`description`) givenNameAttr := sch.ATC.Get(`givenName`) if posixAcct.IsZero() || shadowAcct.IsZero() { panic("missing key ObjectClass instances") } if uidAttr.IsZero() || descAttr.IsZero() || givenNameAttr.IsZero() { panic("missing key AttributeType instances") } aux := NewAuxiliaryObjectClasses() aux.Set(posixAcct) aux.Set(shadowAcct) must := NewRequiredAttributeTypes() must.Set(uidAttr) may := NewPermittedAttributeTypes() may.Set(descAttr) not := NewProhibitedAttributeTypes() not.Set(givenNameAttr) sch.DCRC.Set(&DITContentRule{ OID: NewOID(`0.9.2342.19200300.100.4.5`), Name: NewName(`jesseAccountContentRule`), Aux: aux, Must: must, May: may, Not: not, }) dcr := sch.DCRC.Get(`jesseAccountContentRule`) fmt.Printf("%T.Name: %s\n", *dcr, dcr.Name.Index(0))
Output: schemax.DITContentRule.Name: jesseAccountContentRule
func (*DITContentRules) SetMacros ¶
func (r *DITContentRules) SetMacros(macros *Macros)
SetMacros assigns the *Macros instance to the receiver, allowing subsequent OID resolution capabilities during the addition of new slice elements.
func (*DITContentRules) SetSpecifier ¶
func (r *DITContentRules) SetSpecifier(spec string)
SetSpecifier is a convenience method that executes the SetSpecifier method in iterative fashion for all definitions within the receiver.
func (*DITContentRules) SetUnmarshaler ¶
func (r *DITContentRules) SetUnmarshaler(fn DefinitionUnmarshaler)
SetUnmarshaler is a convenience method that executes the SetUnmarshaler method in iterative fashion for all definitions within the receiver.
func (DITContentRules) String ¶
func (r DITContentRules) String() string
String is a non-functional stringer method needed to satisfy interface type requirements and should not be used. There is no practical application for a list of dITContentRule names or object identifiers in this package.
type DITStructureRule ¶
type DITStructureRule struct { ID RuleID Name Name Description Description Obsolete bool Form *NameForm SuperiorRules DITStructureRuleCollection Extensions *Extensions // contains filtered or unexported fields }
DITStructureRule conforms to the specifications of RFC4512 Section 4.1.7.1.
Example (ManualComposition) ¶
// This example demonstrates an ALTERNATIVE to // raw definition parsing, instead allowing any // given definition to be created from scratch // in a more object oriented fashion. // First, create a minimal subschema just to lookup // ObjectClass or AttributeType instance required, // permitted or forbidden by a given DITContentRule. // Skip if you've already got your own subschema // instance to use. sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() sch.OCC = PopulateDefaultObjectClasses() // Some things we'll need -- alter as desired. person := sch.GetObjectClass(`person`) cn := sch.GetAttributeType(`cn`) ou := sch.GetAttributeType(`ou`) // We need a nameform instance to enable // this structure rule, so we'll create one here. nf := NewNameForm() nf.OID = NewOID(`1.3.6.1.4.1.56521.999.1.2.5.1`) nf.Name = NewName(`genericNameForm`) nf.Description = Description(`Generic test nameForm`) nf.OC = StructuralObjectClass{person} nf.Must.Set(cn) nf.May.Set(ou) // Create a new instance of *DITContentRule // and populate as needed. def := NewDITStructureRule() def.ID = NewRuleID(0) def.Name = NewName(`genericTestRule`, `ruleAltName`) def.Description = Description(`Generic test rule`) def.Form = nf // Make sure validation checks return NO // errors before using your definition! if err := def.Validate(); err != nil { // handle your fatal error } // All checks pass! Use your new definition as needed!
Output:
func NewDITStructureRule ¶ added in v1.1.0
func NewDITStructureRule() *DITStructureRule
NewDITStructureRule returns a newly initialized, yet effectively nil, instance of *DITStructureRule.
Users generally do not need to execute this function unless an instance of the returned type will be manually populated (as opposed to parsing a raw text definition).
func (*DITStructureRule) Equal ¶
func (r *DITStructureRule) Equal(x any) (eq bool)
Equal performs a deep-equal between the receiver and the provided definition type.
Description text is ignored.
Example ¶
dsr1 := &DITStructureRule{} dsr2 := &DITStructureRule{ID: NewRuleID(0)} fmt.Printf("%T instances are equal: %t\n", dsr1, dsr1.Equal(dsr2))
Output: *schemax.DITStructureRule instances are equal: false
func (*DITStructureRule) Info ¶
func (r *DITStructureRule) Info() []byte
Info returns the assigned informational byte slice instance stored within the receiver.
func (*DITStructureRule) IsZero ¶
func (r *DITStructureRule) IsZero() bool
IsZero returns a boolean value indicative of whether the receiver is considered empty or uninitialized.
Example ¶
dsr := &DITStructureRule{} fmt.Printf("%T is zero: %t\n", dsr, dsr.IsZero()) // Output *schemax.DITStructureRule is zero: true
Output:
func (*DITStructureRule) Map ¶
func (r *DITStructureRule) Map() (def map[string][]string)
Map is a convenience method that returns a map[string][]string instance containing the effective contents of the receiver.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() sch.OCC = PopulateDefaultObjectClasses() nf := `( 1.3.6.1.4.1.56521.999.104.17.2.16.4 NAME 'jesseNameForm' DESC 'this is an example Name Form definition' OC account MUST ( cn $ o $ uid ) MAY ( description $ l ) X-ORIGIN 'Jesse Coretta' )` if err := sch.MarshalNameForm(nf); err != nil { panic(err) } dsr := `( 0 NAME 'jesseDSR' DESC 'this is an example DIT Structure Rule' FORM jesseNameForm X-ORIGIN 'Jesse Coretta' )` if err := sch.MarshalDITStructureRule(dsr); err != nil { panic(err) } jdsr := sch.DSRC.Get(`jesseDSR`).Map() fmt.Printf("%T fields: %d\n", jdsr, len(jdsr))
Output: map[string][]string fields: 7
func (*DITStructureRule) SetInfo ¶
func (r *DITStructureRule) SetInfo(info []byte)
SetInfo assigns the byte slice to the receiver. This is a user-leveraged field intended to allow arbitrary information (documentation?) to be assigned to the definition.
func (*DITStructureRule) SetSpecifier ¶
func (r *DITStructureRule) SetSpecifier(spec string)
SetSpecifier assigns a string value to the receiver, useful for placement into configurations that require a type name (e.g.: ditstructurerule). This will be displayed at the beginning of the definition value during the unmarshal or unsafe stringification process.
func (*DITStructureRule) SetUnmarshaler ¶
func (r *DITStructureRule) SetUnmarshaler(fn DefinitionUnmarshaler)
SetUnmarshaler assigns the provided DefinitionUnmarshaler signature value to the receiver. The provided function shall be executed during the unmarshal or unsafe stringification process.
func (DITStructureRule) String ¶
func (r DITStructureRule) String() (def string)
String is an unsafe convenience wrapper for Unmarshal(r). If an error is encountered, an empty string definition is returned. If reliability and error handling are important, use Unmarshal.
func (*DITStructureRule) Type ¶
func (r *DITStructureRule) Type() string
Type returns the formal name of the receiver in order to satisfy signature requirements of the Definition interface type.
func (*DITStructureRule) Validate ¶
func (r *DITStructureRule) Validate() (err error)
Validate returns an error that reflects any fatal condition observed regarding the receiver configuration.
type DITStructureRuleCollection ¶
type DITStructureRuleCollection interface { // Get returns the *DITStructureRule instance retrieved as a result // of a term search, based on Name or ID. If no match is found, // nil is returned. Get(any) *DITStructureRule // Index returns the *DITStructureRule instance stored at the nth // index within the receiver, or nil. Index(int) *DITStructureRule // Equal performs a deep-equal between the receiver and the // interface DITStructureRuleCollection provided. Equal(DITStructureRuleCollection) bool // Set returns an error instance based on an attempt to add // the provided *DITStructureRule instance to the receiver. Set(*DITStructureRule) error // Contains returns the index number and presence boolean that // reflects the result of a term search within the receiver. Contains(any) (int, bool) // String returns a properly-delimited sequence of string // values, either as a Name or OID, for the receiver type. String() string // Label returns the field name associated with the interface // types, or a zero string if no label is appropriate. Label() string // IsZero returns a boolean value indicative of whether the // receiver is considered zero, or undefined. IsZero() bool // Len returns an integer value indicative of the current // number of elements stored within the receiver. Len() int // SetSpecifier assigns a string value to all definitions within // the receiver. This value is used in cases where a definition // type name (e.g.: attributetype, objectclass, etc.) is required. // This value will be displayed at the beginning of the definition // value during the unmarshal or unsafe stringification process. SetSpecifier(string) // SetUnmarshaler assigns the provided DefinitionUnmarshaler // signature to all definitions within the receiver. The provided // function shall be executed during the unmarshal or unsafe // stringification process. SetUnmarshaler(DefinitionUnmarshaler) }
DITStructureRuleCollection describes all of the following types:
- *DITStructureRules
- *SuperiorDITStructureRules
func NewDITStructureRules ¶
func NewDITStructureRules() DITStructureRuleCollection
NewDITStructureRules initializes and returns a new DITStructureRuleCollection interface object.
Example ¶
dsrs := NewDITStructureRules() fmt.Printf("%T is zero: %t\n", dsrs, dsrs.IsZero())
Output: *schemax.DITStructureRules is zero: true
func NewSuperiorDITStructureRules ¶
func NewSuperiorDITStructureRules() DITStructureRuleCollection
NewSuperiorDITStructureRules initializes an embedded instance of *DITStructureRules within the return value.
Example ¶
sups := NewSuperiorDITStructureRules() fmt.Printf("%T is zero: %t\n", sups, sups.IsZero())
Output: *schemax.SuperiorDITStructureRules is zero: true
type DITStructureRules ¶
type DITStructureRules struct {
// contains filtered or unexported fields
}
DITStructureRules is a thread-safe collection of *DITStructureRule slice instances.
func (DITStructureRules) Contains ¶
func (r DITStructureRules) Contains(x any) (int, bool)
Contains is a thread-safe method that returns a collection slice element index integer and a presence-indicative boolean value based on a term search conducted within the receiver.
func (DITStructureRules) Equal ¶
func (r DITStructureRules) Equal(x DITStructureRuleCollection) bool
Equal performs a deep-equal between the receiver and the provided collection type.
func (DITStructureRules) Get ¶
func (r DITStructureRules) Get(x any) *DITStructureRule
Get combines Contains and Index method executions to return an entry based on a term search conducted within the receiver.
func (DITStructureRules) Index ¶
func (r DITStructureRules) Index(idx int) *DITStructureRule
Index is a thread-safe method that returns the nth collection slice element if defined, else nil. This method supports use of negative indices which should be used with special care.
func (*DITStructureRules) IsZero ¶
func (r *DITStructureRules) IsZero() bool
IsZero returns a boolean value indicative of whether the receiver is considered empty or uninitialized.
func (DITStructureRules) Label ¶
func (r DITStructureRules) Label() string
Label returns the known label for the receiver, if one exists.
func (DITStructureRules) Len ¶
func (r DITStructureRules) Len() int
Len is a thread-safe method that returns the effective length of the receiver slice collection.
func (*DITStructureRules) Set ¶
func (r *DITStructureRules) Set(x *DITStructureRule) error
Set is a thread-safe append method that returns an error instance indicative of whether the append operation failed in some manner. Uniqueness is enforced for new elements based on Object Identifier and not the effective Name of the definition, if defined.
func (*DITStructureRules) SetSpecifier ¶
func (r *DITStructureRules) SetSpecifier(spec string)
SetSpecifier is a convenience method that executes the SetSpecifier method in iterative fashion for all definitions within the receiver.
func (*DITStructureRules) SetUnmarshaler ¶
func (r *DITStructureRules) SetUnmarshaler(fn DefinitionUnmarshaler)
SetUnmarshaler is a convenience method that executes the SetUnmarshaler method in iterative fashion for all definitions within the receiver.
func (DITStructureRules) String ¶
func (r DITStructureRules) String() string
String is a non-functional stringer method needed to satisfy interface type requirements and should not be used. See the SuperiorDITStructureRules.String() method instead.
type Definition ¶
type Definition interface { // Equal performs a deep-equal between the receiver and the provided // interface type, if applicable. A boolean value indicative of value // equality is returned. Equal(any) bool // IsZero returns a boolean value indicative of whether the receiver // is considered zero, or undefined. IsZero() bool // Validate returns an error during the validation process. If a non // nil error is returned, it will reveal the nature of the deficiency. // This method is automatically run by the Marshal process, but can be // useful in cases where definitions are crafted manually and not as // a result of raw parsing. Validate() error // String is a convenient, but unsafe, alternative to the recommended // Unmarshal procedure for definitions. This method will Unmarshal a // Definition-based type into a string value. However, if any errors // occur during this process, a zero length string is returned, thus // making this unsafe in situations where error handling is critical. String() string // SetInfo assigns the byte slice to the receiver. This is a user-leveraged // field intended to allow arbitrary information (documentation?) to be // assigned to the definition. SetInfo([]byte) // Info returns the assigned informational byte slice instance stored // within the receiver. Info() []byte // Map returns a map[string][]string instance containing the receiver's // components. A nil map is returned if validation checks fail. Map() map[string][]string // Type returns the formal string name of the type of definition held // by the receiver. The value will be one of: // // - LDAPSyntax // - MatchingRule // - AttributeType // - MatchingRuleUse // - ObjectClass // - DITContentRule // - NameForm // - DITStructureRule Type() string // SetSpecifier assigns a string value to the receiver, useful for placement // into configurations that require a type name (e.g.: attributetype). This // will be displayed at the beginning of the definition value during the // unmarshal or unsafe stringification process. SetSpecifier(string) // SetUnmarshaler assigns the provided DefinitionUnmarshaler signature // value to the receiver. The provided function shall be executed during the // unmarshal or unsafe stringification process. SetUnmarshaler(DefinitionUnmarshaler) // contains filtered or unexported methods }
Definition provides methods common to all discrete definition types:
- *AttributeType
- *ObjectClass
- *LDAPSyntax
- *MatchingRule
- *NameForm
- *DITContentRule
- *DITStructureRule
type DefinitionUnmarshaler ¶
DefinitionUnmarshaler is a first-class "closure" function intended for use in situations where it is desirable to format a given definition during the unmarshal process, i.e.: to add indents and linebreaks.
During the unmarshaling or unsafe stringifaction processes, users may choose to:
• Perform NO formatting whatsoever, producing definitions that span only a single line, or ...
• Use the package-provided formatting closure function appropriate for the definition type, or ...
• Define a custom unmarshal function that honors the defined signature of this type
By default, NO special formatting is performed during unmarshaling or unsafe stringification of definitions.
type Description ¶
type Description string
Description is a single text value intended to describe the nature and purpose of the definition bearing this type in human readable format. All discrete definition types allow values of this type.
func (Description) IsZero ¶
func (r Description) IsZero() bool
IsZero returns a boolean value indicative of whether the receiver is undefined.
func (Description) Label ¶
func (r Description) Label() string
Label returns the known label for the receiver, if one exists.
func (Description) String ¶
func (r Description) String() string
String is a stringer method that returns the string-form of the receiver instance.
type Equality ¶
type Equality struct {
*MatchingRule
}
Equality circumscribes an embedded pointer to an instance of *MatchingRule. This type alias is intended for use solely within instances of AttributeType via its "Equality" struct field.
type Extension ¶ added in v1.1.0
Extension represents any single definition extension such as "X-ORIGIN 'RFC4512'."
func (*Extension) Equal ¶ added in v1.1.0
Equal performs a deep equal between the receiver and input instances, returning a boolean value indicative of equality.
type Extensions ¶
type Extensions struct {
// contains filtered or unexported fields
}
Extensions is a map structure associating a string extension name (e.g.: X-ORIGIN) with a non-zero string value.
func NewExtensions ¶
func NewExtensions() *Extensions
NewExtensions returns a new instance of Extensions, intended for assignment to any definition type.
Example ¶
ext := NewExtensions() fmt.Printf("%T is zero: %t", ext, ext.IsZero())
Output: *schemax.Extensions is zero: true
func (Extensions) Contains ¶ added in v1.1.0
func (r Extensions) Contains(x any) (int, bool)
Contains is a thread-safe method that returns a collection slice element index integer and a presence-indicative boolean value based on a term search conducted within the receiver.
func (Extensions) Equal ¶
func (r Extensions) Equal(x any) (eq bool)
Equal compares the receiver to the provided interface value (which must be of the same effective type). A comparison is performed, and an equality-indicative boolean value is returned.
func (Extensions) Exists ¶
func (r Extensions) Exists(label string) (exists bool)
Exists returns a boolean value indicative of whether the named label exists within the receiver instance.
DEPRECATED: Use Extensions.Contains instead.
func (Extensions) Get ¶ added in v1.1.0
func (r Extensions) Get(label string) *Extension
Get returns an instance of *Extension if its label matches the input value. Case is not important during the evaluation process.
A nil instance is returned if no match found.
func (Extensions) HumanReadable ¶ added in v1.1.0
func (r Extensions) HumanReadable() bool
HumanReadable is a convenience method that searches the receiver for the 'X-NOT-HUMAN-READABLE' extension key and returns a boolean value indicative of whether the key's value is not TRUE. If the key is not found (or is explicitly set to FALSE) for some reason, a boolean value of true is returned as a fallback.
func (Extensions) Index ¶ added in v1.1.0
func (r Extensions) Index(idx int) *Extension
Index is a thread-safe method that returns the nth collection slice element if defined, else nil. This method supports use of negative indices which should be used with special care.
func (*Extensions) IsZero ¶
func (r *Extensions) IsZero() bool
IsZero returns a boolean value indicative of whether the receiver is considered empty or uninitialized.
func (Extensions) Label ¶
func (r Extensions) Label() string
Label returns the known label for the receiver, if one exists.
Example ¶
// Remember! Some labels are invisible, like // this one ... ext := Extensions{} lab := ext.Label() fmt.Printf("%T label: %s (len:%d)\n", ext, lab, len(lab))
Output: schemax.Extensions label: (len:0)
func (Extensions) Len ¶ added in v1.1.0
func (r Extensions) Len() int
func (*Extensions) Set ¶
func (r *Extensions) Set(x ...any)
Set assigns the provided label and value(s) to the receiver instance. The any input argument can be a pre-crafted *Extension instance, or two or more string slices. In the case of strings, the first argument must be a valid extension label (e.g.: X-ORIGIN). All subsequent values are considered values.
All subsequent values (strings or slices of strings) are interpreted as values to be assigned to said label.
func (*Extensions) SetHumanReadable ¶ added in v1.1.0
func (r *Extensions) SetHumanReadable(x bool)
SetHumanReadable creates the X-NOT-HUMAN-READABLE extension with a value 'TRUE' if a boolean value of false is provided. If true, the extension is deleted if present.
func (Extensions) String ¶
func (r Extensions) String() (exts string)
String is a stringer method that returns the receiver data as a compliant schema definition component.
type Kind ¶
type Kind uint8
Kind is an unsigned 8-bit integer that describes the "kind" of ObjectClass definition bearing this type. Only one distinct Kind value may be set for any given ObjectClass definition, and must be set explicitly (no default is implied).
const ( Abstract Kind Structural Auxiliary )
func (Kind) IsZero ¶
IsZero returns a boolean value indicative of whether the receiver is undefined.
type LDAPSyntax ¶
type LDAPSyntax struct { OID OID Description Description Extensions *Extensions // contains filtered or unexported fields }
LDAPSyntax conforms to the specifications of RFC4512 Section 4.1.5.
Example (ManualComposition) ¶
// This example demonstrates an ALTERNATIVE to // raw definition parsing, instead allowing any // given definition to be created from scratch // in a more object oriented fashion. def := NewLDAPSyntax() def.OID = NewOID(`1.3.6.1.4.1.1466.115.121.1.4`) def.Description = Description(`Audio`) def.Extensions.Set(`X-NOT-HUMAN-READABLE`, `TRUE`) def.Extensions.Set(`X-ORIGIN`, `RFC4517`) // Make sure validation checks return NO // errors before using your definition! if err := def.Validate(); err != nil { // handle your fatal error } // All checks pass! Use your new definition as needed!
Output:
func NewLDAPSyntax ¶ added in v1.1.0
func NewLDAPSyntax() *LDAPSyntax
NewLDAPSyntax returns a newly initialized, yet effectively nil, instance of *LDAPSyntax.
Users generally do not need to execute this function unless an instance of the returned type will be manually populated (as opposed to parsing a raw text definition).
func (*LDAPSyntax) Equal ¶
func (r *LDAPSyntax) Equal(x any) (eq bool)
Equal performs a deep-equal between the receiver and the provided definition type.
Description text is ignored.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() syn1 := &LDAPSyntax{} syn2 := sch.LSC.Get(`1.3.6.1.4.1.1466.115.121.1.4`) // Audio per RFC4517 fmt.Printf("%T instances are equal: %t\n", syn1, syn1.Equal(syn2))
Output: *schemax.LDAPSyntax instances are equal: false
func (*LDAPSyntax) HumanReadable ¶
func (r *LDAPSyntax) HumanReadable() bool
HumanReadable is a convenience wrapper for Extensions.HumanReadable().
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() audio := sch.LSC.Get(`1.3.6.1.4.1.1466.115.121.1.4`) // Audio per RFC4517 fmt.Printf("%T (%s) is Human Readable: %t\n", audio, audio.OID, audio.HumanReadable())
Output: *schemax.LDAPSyntax (1.3.6.1.4.1.1466.115.121.1.4) is Human Readable: false
func (*LDAPSyntax) Info ¶
func (r *LDAPSyntax) Info() []byte
Info returns the assigned informational byte slice instance stored within the receiver.
func (*LDAPSyntax) IsZero ¶
func (r *LDAPSyntax) IsZero() bool
IsZero returns a boolean value indicative of whether the receiver is considered empty or uninitialized.
Example ¶
ls := &LDAPSyntax{} fmt.Printf("%T is zero: %t\n", ls, ls.IsZero()) // Output *schemax.LDAPSyntax is zero: true
Output:
func (LDAPSyntax) Label ¶
func (r LDAPSyntax) Label() string
Label returns the known label for the receiver, if one exists.
Example ¶
ls := LDAPSyntax{} lab := ls.Label() fmt.Printf("%T label: %s (len:%d)\n", ls, lab, len(lab))
Output: schemax.LDAPSyntax label: SYNTAX (len:6)
func (*LDAPSyntax) Map ¶
func (r *LDAPSyntax) Map() (def map[string][]string)
Map is a convenience method that returns a map[string][]string instance containing the effective contents of the receiver.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() syn := sch.LSC.Get(`1.3.6.1.4.1.1466.115.121.1.15`).Map() fmt.Printf("%T fields: %d\n", syn, len(syn))
Output: map[string][]string fields: 5
func (*LDAPSyntax) SetHumanReadable ¶
func (r *LDAPSyntax) SetHumanReadable(x bool)
SetHumanReadable sets the LDAPSyntax Extension field `X-NOT-HUMAN-READABLE` as `TRUE` when given a value of false, and deletes said field when given a value of true.
func (*LDAPSyntax) SetInfo ¶
func (r *LDAPSyntax) SetInfo(info []byte)
SetInfo assigns the byte slice to the receiver. This is a user-leveraged field intended to allow arbitrary information (documentation?) to be assigned to the definition.
func (*LDAPSyntax) SetSpecifier ¶
func (r *LDAPSyntax) SetSpecifier(spec string)
SetSpecifier assigns a string value to the receiver, useful for placement into configurations that require a type name (e.g.: attributetype). This will be displayed at the beginning of the definition value during the unmarshal or unsafe stringification process.
func (*LDAPSyntax) SetUnmarshaler ¶
func (r *LDAPSyntax) SetUnmarshaler(fn DefinitionUnmarshaler)
SetUnmarshaler assigns the provided DefinitionUnmarshaler signature value to the receiver. The provided function shall be executed during the unmarshal or unsafe stringification process.
func (LDAPSyntax) String ¶
func (r LDAPSyntax) String() (def string)
String is an unsafe convenience wrapper for Unmarshal(r). If an error is encountered, an empty string definition is returned. If reliability and error handling are important, use Unmarshal.
func (*LDAPSyntax) Type ¶
func (r *LDAPSyntax) Type() string
Type returns the formal name of the receiver in order to satisfy signature requirements of the Definition interface type.
func (*LDAPSyntax) Validate ¶
func (r *LDAPSyntax) Validate() (err error)
Validate returns an error that reflects any fatal condition observed regarding the receiver configuration.
type LDAPSyntaxCollection ¶
type LDAPSyntaxCollection interface { // Get returns the *LDAPSyntax instance retrieved as a result // of a term search, based on Name or OID. If no match is found, // nil is returned. Get(any) *LDAPSyntax // Index returns the *LDAPSyntax instance stored at the nth // index within the receiver, or nil. Index(int) *LDAPSyntax // Equal performs a deep-equal between the receiver and the // interface LDAPSyntaxCollection provided. Equal(LDAPSyntaxCollection) bool // Set returns an error instance based on an attempt to add // the provided *AttributeType instance to the receiver. Set(*LDAPSyntax) error // Contains returns the index number and presence boolean that // reflects the result of a term search within the receiver. Contains(any) (int, bool) // String returns a properly-delimited sequence of string // values, either as a Name or OID, for the receiver type. String() string // Label returns the field name associated with the interface // types, or a zero string if no label is appropriate. Label() string // IsZero returns a boolean value indicative of whether the // receiver is considered zero, or undefined. IsZero() bool // Len returns an integer value indicative of the current // number of elements stored within the receiver. Len() int // SetSpecifier assigns a string value to all definitions within // the receiver. This value is used in cases where a definition // type name (e.g.: attributetype, objectclass, etc.) is required. // This value will be displayed at the beginning of the definition // value during the unmarshal or unsafe stringification process. SetSpecifier(string) // SetUnmarshaler assigns the provided DefinitionUnmarshaler // signature to all definitions within the receiver. The provided // function shall be executed during the unmarshal or unsafe // stringification process. SetUnmarshaler(DefinitionUnmarshaler) }
LDAPSyntaxTypeCollection describes all LDAPSyntax-based types.
func NewLDAPSyntaxes ¶
func NewLDAPSyntaxes() LDAPSyntaxCollection
NewLDAPSyntaxes initializes and returns a new LDAPSyntaxesCollection interface object.
Example ¶
lsm := NewLDAPSyntaxes() fmt.Printf("%T is zero: %t", lsm, lsm.IsZero())
Output: *schemax.LDAPSyntaxes is zero: true
func PopulateDefaultLDAPSyntaxes ¶
func PopulateDefaultLDAPSyntaxes() (lsc LDAPSyntaxCollection)
PopulateDefaultLDAPSyntaxes returns a new auto-populated instance of LDAPSyntaxes.
Within this structure are all of the following:
• Syntax definitions from RFC2307 (imported from go-schemax/rfc2307)
• Syntax definitions from RFC4517 (imported from go-schemax/rfc4517)
• Syntax definitions from RFC4523 (imported from go-schemax/rfc4523)
• Syntax definitions from RFC4530 (imported from go-schemax/rfc4530)
type LDAPSyntaxes ¶
type LDAPSyntaxes struct {
// contains filtered or unexported fields
}
LDAPSyntaxes is a thread-safe collection of *LDAPSyntax slice instances.
func (LDAPSyntaxes) Contains ¶
func (r LDAPSyntaxes) Contains(x any) (int, bool)
Contains is a thread-safe method that returns a collection slice element index integer and a presence-indicative boolean value based on a term search conducted within the receiver.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() _, found := sch.LSC.Contains(`1.3.6.1.4.1.1466.115.121.1.4`) fmt.Printf("syntax exists: %t\n", found)
Output: syntax exists: true
func (LDAPSyntaxes) Equal ¶
func (r LDAPSyntaxes) Equal(x LDAPSyntaxCollection) bool
Equal performs a deep-equal between the receiver and the provided collection type.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() otherLSC := NewLDAPSyntaxes() same := sch.LSC.Equal(otherLSC) fmt.Printf("%T instances are equal: %t\n", sch.LSC, same)
Output: *schemax.LDAPSyntaxes instances are equal: false
func (LDAPSyntaxes) Get ¶
func (r LDAPSyntaxes) Get(x any) *LDAPSyntax
Get combines Contains and Index method executions to return an entry based on a term search conducted within the receiver.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() if ls := sch.LSC.Get(`1.3.6.1.4.1.1466.115.121.1.4`); !ls.IsZero() { fmt.Printf("%T OID: %s\n", ls, ls.OID) }
Output: *schemax.LDAPSyntax OID: 1.3.6.1.4.1.1466.115.121.1.4
func (LDAPSyntaxes) Index ¶
func (r LDAPSyntaxes) Index(idx int) *LDAPSyntax
Index is a thread-safe method that returns the nth collection slice element if defined, else nil. This method supports use of negative indices which should be used with special care.
func (LDAPSyntaxes) IsZero ¶
func (r LDAPSyntaxes) IsZero() bool
IsZero returns a boolean value indicative of whether the receiver is considered empty or uninitialized.
func (LDAPSyntaxes) Label ¶
func (r LDAPSyntaxes) Label() string
Label returns the known label for the receiver, if one exists.
func (LDAPSyntaxes) Len ¶
func (r LDAPSyntaxes) Len() int
Len is a thread-safe method that returns the effective length of the receiver slice collection.
func (*LDAPSyntaxes) Set ¶
func (r *LDAPSyntaxes) Set(x *LDAPSyntax) error
Set is a thread-safe append method that returns an error instance indicative of whether the append operation failed in some manner. Uniqueness is enforced for new elements based on Object Identifier and not the effective Name of the definition, if defined.
func (*LDAPSyntaxes) SetMacros ¶
func (r *LDAPSyntaxes) SetMacros(macros *Macros)
SetMacros assigns the *Macros instance to the receiver, allowing subsequent OID resolution capabilities during the addition of new slice elements.
func (*LDAPSyntaxes) SetSpecifier ¶
func (r *LDAPSyntaxes) SetSpecifier(spec string)
SetSpecifier is a convenience method that executes the SetSpecifier method in iterative fashion for all definitions within the receiver.
func (*LDAPSyntaxes) SetUnmarshaler ¶
func (r *LDAPSyntaxes) SetUnmarshaler(fn DefinitionUnmarshaler)
SetUnmarshaler is a convenience method that executes the SetUnmarshaler method in iterative fashion for all definitions within the receiver.
func (LDAPSyntaxes) String ¶
func (r LDAPSyntaxes) String() string
String is a non-functional stringer method needed to satisfy interface type requirements and should not be used. There is no practical application for a list of ldapSyntax object identifiers in this package.
type Macros ¶
Macros is a map structure associating a string value known as a "macro" name with a dot-delimited ASN.1 object identifier.
Use of instances of this type is limited to scenarios involving LDAP implementations that support OID macros for certain schema definition elements. Generally speaking, it is best to avoid macros if at all possible.
func (*Macros) IsZero ¶
IsZero returns a boolean value indicative of whether the receiver is considered zero, or undefined.
type MatchingRule ¶
type MatchingRule struct { OID OID Name Name Description Description Obsolete bool Syntax *LDAPSyntax Extensions *Extensions // contains filtered or unexported fields }
MatchingRule conforms to the specifications of RFC4512 Section 4.1.3.
Example (ManualComposition) ¶
// This example demonstrates an ALTERNATIVE to // raw definition parsing, instead allowing any // given definition to be created from scratch // in a more object oriented fashion. // First, create a minimal subschema just to lookup // dependencies such as an LDAPSyntax instance. Skip // if you've already got your own subschema instance // to use. sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() // Get (and confirm) needed syntax syn := sch.LSC.Get(`1.3.6.1.4.1.1466.115.121.1.15`) if syn.IsZero() { // handle your fatal error ... } // Create a new instance of *MatchingRule // and populate as needed. def := NewMatchingRule() def.Name = NewName(`caseIgnoreMatch`) def.OID = NewOID(`2.5.13.2`) def.Syntax = syn def.Extensions.Set(`X-ORIGIN`, `RFC4517`) // Make sure validation checks return NO // errors before using your definition! if err := def.Validate(); err != nil { // handle your fatal error } // All checks pass! Use your new definition as needed!
Output:
func NewMatchingRule ¶ added in v1.1.0
func NewMatchingRule() *MatchingRule
NewMatchingRule returns a newly initialized, yet effectively nil, instance of *MatchingRule.
Users generally do not need to execute this function unless an instance of the returned type will be manually populated (as opposed to parsing a raw text definition).
func (*MatchingRule) Equal ¶
func (r *MatchingRule) Equal(x any) (eq bool)
Equal performs a deep-equal between the receiver and the provided definition type.
Description text is ignored.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() mr1 := sch.MRC.Get(`caseIgnoreMatch`) mr2 := sch.MRC.Get(`caseExactMatch`) fmt.Printf("%T instances are equal: %t\n", mr1, mr1.Equal(mr2))
Output: *schemax.MatchingRule instances are equal: false
func (*MatchingRule) Info ¶
func (r *MatchingRule) Info() []byte
Info returns the assigned informational byte slice instance stored within the receiver.
func (*MatchingRule) IsZero ¶
func (r *MatchingRule) IsZero() bool
IsZero returns a boolean value indicative of whether the receiver is considered empty or uninitialized.
Example ¶
mr := &MatchingRule{} fmt.Printf("%T is zero: %t\n", mr, mr.IsZero()) // Output *schemax.MatchingRule is zero: true
Output:
func (*MatchingRule) Map ¶
func (r *MatchingRule) Map() (def map[string][]string)
Map is a convenience method that returns a map[string][]string instance containing the effective contents of the receiver.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() mr := sch.MRC.Get(`2.5.13.1`).Map() fmt.Printf("%T fields: %d\n", mr, len(mr))
Output: map[string][]string fields: 6
func (*MatchingRule) SetInfo ¶
func (r *MatchingRule) SetInfo(info []byte)
SetInfo assigns the byte slice to the receiver. This is a user-leveraged field intended to allow arbitrary information (documentation?) to be assigned to the definition.
func (*MatchingRule) SetSpecifier ¶
func (r *MatchingRule) SetSpecifier(spec string)
SetSpecifier assigns a string value to the receiver, useful for placement into configurations that require a type name (e.g.: matchingrule). This will be displayed at the beginning of the definition value during the unmarshal or unsafe stringification process.
func (*MatchingRule) SetUnmarshaler ¶
func (r *MatchingRule) SetUnmarshaler(fn DefinitionUnmarshaler)
SetUnmarshaler assigns the provided DefinitionUnmarshaler signature value to the receiver. The provided function shall be executed during the unmarshal or unsafe stringification process.
func (MatchingRule) String ¶
func (r MatchingRule) String() (def string)
String is an unsafe convenience wrapper for Unmarshal(r). If an error is encountered, an empty string definition is returned. If reliability and error handling are important, use Unmarshal.
func (*MatchingRule) Type ¶
func (r *MatchingRule) Type() string
Type returns the formal name of the receiver in order to satisfy signature requirements of the Definition interface type.
func (*MatchingRule) Validate ¶
func (r *MatchingRule) Validate() (err error)
Validate returns an error that reflects any fatal condition observed regarding the receiver configuration.
type MatchingRuleCollection ¶
type MatchingRuleCollection interface { // Get returns the *MatchingRule instance retrieved as a result // of a term search, based on Name or OID. If no match is found, // nil is returned. Get(any) *MatchingRule // Index returns the *MatchingRule instance stored at the nth // index within the receiver, or nil. Index(int) *MatchingRule // Equal performs a deep-equal between the receiver and the // interface MatchingRuleCollection provided. Equal(MatchingRuleCollection) bool // Set returns an error instance based on an attempt to add // the provided *MatchingRule instance to the receiver. Set(*MatchingRule) error // Contains returns the index number and presence boolean that // reflects the result of a term search within the receiver. Contains(any) (int, bool) // String returns a properly-delimited sequence of string // values, either as a Name or OID, for the receiver type. String() string // Label returns the field name associated with the interface // types, or a zero string if no label is appropriate. Label() string // IsZero returns a boolean value indicative of whether the // receiver is considered zero, or undefined. IsZero() bool // Len returns an integer value indicative of the current // number of elements stored within the receiver. Len() int // SetSpecifier assigns a string value to all definitions within // the receiver. This value is used in cases where a definition // type name (e.g.: attributetype, objectclass, etc.) is required. // This value will be displayed at the beginning of the definition // value during the unmarshal or unsafe stringification process. SetSpecifier(string) // SetUnmarshaler assigns the provided DefinitionUnmarshaler // signature to all definitions within the receiver. The provided // function shall be executed during the unmarshal or unsafe // stringification process. SetUnmarshaler(DefinitionUnmarshaler) }
MatchingRuleCollection describes all MatchingRules-based types.
func NewMatchingRules ¶
func NewMatchingRules() MatchingRuleCollection
NewMatchingRules initializes and returns a new MatchingRulesCollection interface object.
Example ¶
mrm := NewMatchingRules() fmt.Printf("%T is zero: %t", mrm, mrm.IsZero())
Output: *schemax.MatchingRules is zero: true
func PopulateDefaultMatchingRules ¶
func PopulateDefaultMatchingRules() (mrc MatchingRuleCollection)
PopulateDefaultMatchingRules returns a new auto-populated instance of MatchingRules. Within this structure are all of the following:
• Matching rules from RFC2307 (imported from go-schemax/rfc2307)
• Matching rules from RFC4517 (imported from go-schemax/rfc4517)
• Matching rules from RFC4523 (imported from go-schemax/rfc4523)
• Matching rules from RFC4530 (imported from go-schemax/rfc4530)
type MatchingRuleUse ¶
type MatchingRuleUse struct { OID OID Name Name Description Description Obsolete bool Applies AttributeTypeCollection Extensions *Extensions // contains filtered or unexported fields }
MatchingRuleUse conforms to the specifications of RFC4512 Section 4.1.4.
Example (ManualComposition) ¶
// This example demonstrates an ALTERNATIVE to // raw definition parsing, instead allowing any // given definition to be created from scratch // in a more object oriented fashion. Please note // it is very unusual for matchingRuleUse instances // to be created manually in this fashion. // First, create a minimal subschema just to lookup // dependencies such as an LDAPSyntax instance. Skip // if you've already got your own subschema instance // to use. sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() // Create a new instance of *MatchingRule // and populate as needed. def := NewMatchingRuleUse() def.Name = NewName(`objectIdentifierFirstComponentMatch`) def.OID = NewOID(`2.5.13.30`) // specify a list of attributetypes applicable to the // matchingRule identified by 2.5.13.30. applied := []string{ `objectClasses`, `attributeTypes`, `matchingRules`, `matchingRuleUse`, `ldapSyntaxes`, `dITContentRules`, `nameForms`, } // Cycle through the above list of applied // *AttributeType names, looking-up and // setting each one within the MRU. for _, apply := range applied { if at := sch.GetAttributeType(apply); !at.IsZero() { def.Applies.Set(at) } } // Make sure validation checks return NO // errors before using your definition! if err := def.Validate(); err != nil { // handle your fatal error } // All checks pass! Use your new definition as needed!
Output:
func NewMatchingRuleUse ¶ added in v1.1.0
func NewMatchingRuleUse() *MatchingRuleUse
NewMatchingRuleUse returns a newly initialized, yet effectively nil, instance of *MatchingRuleUse.
Users generally do not need to execute this function unless an instance of the returned type will be manually populated (as opposed to parsing a raw text definition).
func (*MatchingRuleUse) Equal ¶
func (r *MatchingRuleUse) Equal(x any) (eq bool)
Equal performs a deep-equal between the receiver and the provided collection type.
Description text is ignored.
func (*MatchingRuleUse) Info ¶
func (r *MatchingRuleUse) Info() []byte
Info returns the assigned informational byte slice instance stored within the receiver.
func (*MatchingRuleUse) IsZero ¶
func (r *MatchingRuleUse) IsZero() bool
IsZero returns a boolean value indicative of whether the receiver is considered empty or uninitialized.
Example ¶
mru := &MatchingRuleUse{} fmt.Printf("%T is zero: %t\n", mru, mru.IsZero()) // Output *schemax.MatchingRuleUse is zero: true
Output:
func (*MatchingRuleUse) Map ¶
func (r *MatchingRuleUse) Map() (def map[string][]string)
Map is a convenience method that returns a map[string][]string instance containing the effective contents of the receiver.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() sch.MRUC.Refresh(sch.ATC) mru := sch.MRUC.Get(`2.5.13.1`).Map() fmt.Printf("%T fields: %d\n", mru, len(mru))
Output: map[string][]string fields: 5
func (*MatchingRuleUse) SetInfo ¶
func (r *MatchingRuleUse) SetInfo(info []byte)
SetInfo assigns the byte slice to the receiver. This is a user-leveraged field intended to allow arbitrary information (documentation?) to be assigned to the definition.
func (*MatchingRuleUse) SetSpecifier ¶
func (r *MatchingRuleUse) SetSpecifier(spec string)
SetSpecifier assigns a string value to the receiver, useful for placement into configurations that require a type name (e.g.: matchingruleuse). This will be displayed at the beginning of the definition value during the unmarshal or unsafe stringification process.
func (*MatchingRuleUse) SetUnmarshaler ¶
func (r *MatchingRuleUse) SetUnmarshaler(fn DefinitionUnmarshaler)
SetUnmarshaler assigns the provided DefinitionUnmarshaler signature value to the receiver. The provided function shall be executed during the unmarshal or unsafe stringification process.
func (MatchingRuleUse) String ¶
func (r MatchingRuleUse) String() (def string)
String is an unsafe convenience wrapper for Unmarshal(r). If an error is encountered, an empty string definition is returned. If reliability and error handling are important, use Unmarshal.
func (*MatchingRuleUse) Type ¶
func (r *MatchingRuleUse) Type() string
Type returns the formal name of the receiver in order to satisfy signature requirements of the Definition interface type.
func (*MatchingRuleUse) Validate ¶
func (r *MatchingRuleUse) Validate() (err error)
Validate returns an error that reflects any fatal condition observed regarding the receiver configuration.
type MatchingRuleUseCollection ¶
type MatchingRuleUseCollection interface { // Get returns the *MatchingRuleUse instance retrieved as a result // of a term search, based on Name or OID. If no match is found, // nil is returned. Get(any) *MatchingRuleUse // Index returns the *MatchingRuleUse instance stored at the nth // index within the receiver, or nil. Index(int) *MatchingRuleUse // Equal performs a deep-equal between the receiver and the // interface MatchingRuleUseCollection provided. Equal(MatchingRuleUseCollection) bool // Set returns an error instance based on an attempt to add // the provided *MatchingRuleUse instance to the receiver. Set(*MatchingRuleUse) error // Refresh will update the collection of MatchingRuleUse // instances based on the contents of the provided instance // of AttributeTypeCollection. Refresh(AttributeTypeCollection) error // Contains returns the index number and presence boolean that // reflects the result of a term search within the receiver. Contains(any) (int, bool) // String returns a properly-delimited sequence of string // values, either as a Name or OID, for the receiver type. String() string // Label returns the field name associated with the interface // types, or a zero string if no label is appropriate. Label() string // IsZero returns a boolean value indicative of whether the // receiver is considered zero, or undefined. IsZero() bool // Len returns an integer value indicative of the current // number of elements stored within the receiver. Len() int // SetSpecifier assigns a string value to all definitions within // the receiver. This value is used in cases where a definition // type name (e.g.: attributetype, objectclass, etc.) is required. // This value will be displayed at the beginning of the definition // value during the unmarshal or unsafe stringification process. SetSpecifier(string) // SetUnmarshaler assigns the provided DefinitionUnmarshaler // signature to all definitions within the receiver. The provided // function shall be executed during the unmarshal or unsafe // stringification process. SetUnmarshaler(DefinitionUnmarshaler) }
MatchingRuleUseCollection describes all MatchingRuleUses-based types.
func NewMatchingRuleUses ¶
func NewMatchingRuleUses() MatchingRuleUseCollection
NewMatchingRuleUses initializes and returns a new MatchingRuleUsesCollection interface object.
Example ¶
mrum := NewMatchingRuleUses() fmt.Printf("%T is zero: %t", mrum, mrum.IsZero())
Output: *schemax.MatchingRuleUses is zero: true
type MatchingRuleUses ¶
type MatchingRuleUses struct {
// contains filtered or unexported fields
}
MatchingRuleUses is a thread-safe collection of *MatchingRuleUse slice instances.
func (MatchingRuleUses) Contains ¶
func (r MatchingRuleUses) Contains(x any) (int, bool)
Contains is a thread-safe method that returns a collection slice element index integer and a presence-indicative boolean value based on a term search conducted within the receiver.
func (MatchingRuleUses) Equal ¶
func (r MatchingRuleUses) Equal(x MatchingRuleUseCollection) bool
Equal performs a deep-equal between the receiver and the provided collection type.
func (MatchingRuleUses) Get ¶
func (r MatchingRuleUses) Get(x any) *MatchingRuleUse
Get combines Contains and Index method executions to return an entry based on a term search conducted within the receiver.
func (MatchingRuleUses) Index ¶
func (r MatchingRuleUses) Index(idx int) *MatchingRuleUse
Index is a thread-safe method that returns the nth collection slice element if defined, else nil. This method supports use of negative indices which should be used with special care.
func (MatchingRuleUses) IsZero ¶
func (r MatchingRuleUses) IsZero() bool
IsZero returns a boolean value indicative of whether the receiver is considered empty or uninitialized.
func (MatchingRuleUses) Label ¶
func (r MatchingRuleUses) Label() string
Label returns the known label for the receiver, if one exists.
func (MatchingRuleUses) Len ¶
func (r MatchingRuleUses) Len() int
Len is a thread-safe method that returns the effective length of the receiver slice collection.
func (*MatchingRuleUses) Refresh ¶
func (r *MatchingRuleUses) Refresh(atc AttributeTypeCollection) (err error)
Refresh accepts an AttributeTypeCollection which will be processed and used to create new, or update existing, *MatchingRuleUse instances within the receiver.
func (*MatchingRuleUses) Set ¶
func (r *MatchingRuleUses) Set(x *MatchingRuleUse) error
Set is a thread-safe append method that returns an error instance indicative of whether the append operation failed in some manner. Uniqueness is enforced for new elements based on Object Identifier and not the effective Name of the definition, if defined.
func (*MatchingRuleUses) SetSpecifier ¶
func (r *MatchingRuleUses) SetSpecifier(spec string)
SetSpecifier is a convenience method that executes the SetSpecifier method in iterative fashion for all definitions within the receiver.
func (*MatchingRuleUses) SetUnmarshaler ¶
func (r *MatchingRuleUses) SetUnmarshaler(fn DefinitionUnmarshaler)
SetUnmarshaler is a convenience method that executes the SetUnmarshaler method in iterative fashion for all definitions within the receiver.
func (MatchingRuleUses) String ¶
func (r MatchingRuleUses) String() string
String is a non-functional stringer method needed to satisfy interface type requirements and should not be used. There is no practical application for a list of matchingRuleUse names or object identifiers in this package.
type MatchingRules ¶
type MatchingRules struct {
// contains filtered or unexported fields
}
MatchingRules is a thread-safe collection of *MatchingRule slice instances.
func (MatchingRules) Contains ¶
func (r MatchingRules) Contains(x any) (int, bool)
Contains is a thread-safe method that returns a collection slice element index integer and a presence-indicative boolean value based on a term search conducted within the receiver.
func (MatchingRules) Equal ¶
func (r MatchingRules) Equal(x MatchingRuleCollection) bool
Equal performs a deep-equal between the receiver and the provided collection type.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() otherMRC := NewMatchingRules() same := sch.MRC.Equal(otherMRC) fmt.Printf("%T instances are equal: %t\n", sch.MRC, same)
Output: *schemax.MatchingRules instances are equal: false
func (MatchingRules) Get ¶
func (r MatchingRules) Get(x any) *MatchingRule
Get combines Contains and Index method executions to return an entry based on a term search conducted within the receiver.
func (MatchingRules) Index ¶
func (r MatchingRules) Index(idx int) *MatchingRule
Index is a thread-safe method that returns the nth collection slice element if defined, else nil. This method supports use of negative indices which should be used with special care.
func (MatchingRules) IsZero ¶
func (r MatchingRules) IsZero() bool
IsZero returns a boolean value indicative of whether the receiver is considered empty or uninitialized.
func (MatchingRules) Label ¶
func (r MatchingRules) Label() string
Label returns the known label for the receiver, if one exists.
func (MatchingRules) Len ¶
func (r MatchingRules) Len() int
Len is a thread-safe method that returns the effective length of the receiver slice collection.
func (*MatchingRules) Set ¶
func (r *MatchingRules) Set(x *MatchingRule) error
Set is a thread-safe append method that returns an error instance indicative of whether the append operation failed in some manner. Uniqueness is enforced for new elements based on Object Identifier and not the effective Name of the definition, if defined.
func (*MatchingRules) SetMacros ¶
func (r *MatchingRules) SetMacros(macros *Macros)
SetMacros assigns the *Macros instance to the receiver, allowing subsequent OID resolution capabilities during the addition of new slice elements.
func (*MatchingRules) SetSpecifier ¶
func (r *MatchingRules) SetSpecifier(spec string)
SetSpecifier is a convenience method that executes the SetSpecifier method in iterative fashion for all definitions within the receiver.
func (*MatchingRules) SetUnmarshaler ¶
func (r *MatchingRules) SetUnmarshaler(fn DefinitionUnmarshaler)
SetUnmarshaler is a convenience method that executes the SetUnmarshaler method in iterative fashion for all definitions within the receiver.
func (MatchingRules) String ¶
func (r MatchingRules) String() string
String is a non-functional stringer method needed to satisfy interface type requirements and should not be used. There is no practical application for a list of matchingRule names or object identifiers in this package.
type Name ¶
type Name collection
func (Name) Contains ¶
Contains returns the index number and presence boolean that reflects the result of a term search.
func (Name) Equal ¶
Equal returns a boolean indicative of whether the value(s) provided match the receiver.
func (*Name) IsZero ¶
IsZero returns a boolean value indicative of whether the receiver is undefined.
Example ¶
n := &Name{} fmt.Printf("%T is zero: %t\n", n, n.IsZero()) // Output *schemax.Name is zero: true
Output:
func (Name) Len ¶
Len returns an integer indicative of the number of NAME values present within the receiver.
type NameForm ¶
type NameForm struct { OID OID Name Name Description Description Obsolete bool OC StructuralObjectClass Must AttributeTypeCollection May AttributeTypeCollection Extensions *Extensions // contains filtered or unexported fields }
NameForm conforms to the specifications of RFC4512 Section 4.1.7.2.
Example (ManualComposition) ¶
// This example demonstrates an ALTERNATIVE to // raw definition parsing, instead allowing any // given definition to be created from scratch // in a more object oriented fashion. // First, create a minimal subschema just to lookup // dependencies as needed. Skip if you've already got // your own subschema instance to use. sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() sch.OCC = PopulateDefaultObjectClasses() // Some things we'll need -- alter as desired. person := sch.GetObjectClass(`person`) cn := sch.GetAttributeType(`cn`) ou := sch.GetAttributeType(`ou`) def := NewNameForm() def.OID = NewOID(`1.3.6.1.4.1.56521.999.1.2.5.1`) def.Name = NewName(`genericExampleNameForm`) def.Description = Description(`Generic test nameForm`) def.OC = StructuralObjectClass{person} def.Must.Set(cn) def.May.Set(ou) // Make sure validation checks return NO // errors before using your definition! if err := def.Validate(); err != nil { // handle your fatal error } // All checks pass! Use your new definition as needed!
Output:
func NewNameForm ¶ added in v1.1.0
func NewNameForm() *NameForm
NewNameForm returns a newly initialized, yet effectively nil, instance of *NameForm.
Users generally do not need to execute this function unless an instance of the returned type will be manually populated (as opposed to parsing a raw text definition).
func (*NameForm) Equal ¶
Equal performs a deep-equal between the receiver and the provided definition type.
Description text is ignored.
func (*NameForm) Info ¶
Info returns the assigned informational byte slice instance stored within the receiver.
func (*NameForm) IsZero ¶
IsZero returns a boolean value indicative of whether the receiver is considered empty or uninitialized.
Example ¶
nf := &NameForm{} fmt.Printf("%T is zero: %t\n", nf, nf.IsZero()) // Output *schemax.NameForm is zero: true
Output:
func (*NameForm) Map ¶
Map is a convenience method that returns a map[string][]string instance containing the effective contents of the receiver.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() sch.OCC = PopulateDefaultObjectClasses() sch.NFC = NewNameForms() myDef := `( 1.3.6.1.4.1.56521.999.104.17.2.16.4 NAME 'jesseNameForm' DESC 'this is an example Name Form definition' OC account MUST ( cn $ o $ uid ) MAY ( description $ l ) X-ORIGIN 'Jesse Coretta' )` if err := sch.MarshalNameForm(myDef); err != nil { panic(err) } jnf := sch.NFC.Get(`jesseNameForm`).Map() fmt.Printf("%T fields: %d\n", jnf, len(jnf))
Output: map[string][]string fields: 9
func (*NameForm) SetInfo ¶
SetInfo assigns the byte slice to the receiver. This is a user-leveraged field intended to allow arbitrary information (documentation?) to be assigned to the definition.
func (*NameForm) SetSpecifier ¶
SetSpecifier assigns a string value to the receiver, useful for placement into configurations that require a type name (e.g.: nameform). This will be displayed at the beginning of the definition value during the unmarshal or unsafe stringification process.
func (*NameForm) SetUnmarshaler ¶
func (r *NameForm) SetUnmarshaler(fn DefinitionUnmarshaler)
SetUnmarshaler assigns the provided DefinitionUnmarshaler signature value to the receiver. The provided function shall be executed during the unmarshal or unsafe stringification process.
func (NameForm) String ¶
String is an unsafe convenience wrapper for Unmarshal(r). If an error is encountered, an empty string definition is returned. If reliability and error handling are important, use Unmarshal.
type NameFormCollection ¶
type NameFormCollection interface { // Get returns the *NameForm instance retrieved as a result // of a term search, based on Name or OID. If no match is found, // nil is returned. Get(any) *NameForm // Index returns the *NameForm instance stored at the nth // index within the receiver, or nil. Index(int) *NameForm // Equal performs a deep-equal between the receiver and the // interface NameFormCollection provided. Equal(NameFormCollection) bool // Set returns an error instance based on an attempt to add // the provided *NameForm instance to the receiver. Set(*NameForm) error // Contains returns the index number and presence boolean that // reflects the result of a term search within the receiver. Contains(any) (int, bool) // String returns a properly-delimited sequence of string // values, either as a Name or OID, for the receiver type. String() string // Label returns the field name associated with the interface // types, or a zero string if no label is appropriate. Label() string // IsZero returns a boolean value indicative of whether the // receiver is considered zero, or undefined. IsZero() bool // Len returns an integer value indicative of the current // number of elements stored within the receiver. Len() int // SetSpecifier assigns a string value to all definitions within // the receiver. This value is used in cases where a definition // type name (e.g.: attributetype, objectclass, etc.) is required. // This value will be displayed at the beginning of the definition // value during the unmarshal or unsafe stringification process. SetSpecifier(string) // SetUnmarshaler assigns the provided DefinitionUnmarshaler // signature to all definitions within the receiver. The provided // function shall be executed during the unmarshal or unsafe // stringification process. SetUnmarshaler(DefinitionUnmarshaler) }
NameFormCollection describes all NameForms-based types.
func NewNameForms ¶
func NewNameForms() NameFormCollection
NewNameForms initializes and returns a new NameFormCollection interface object.
Example ¶
nfm := NewNameForms() fmt.Printf("%T is zero: %t", nfm, nfm.IsZero())
Output: *schemax.NameForms is zero: true
type NameForms ¶
type NameForms struct {
// contains filtered or unexported fields
}
NameForms is a thread-safe collection of *NameForm slice instances.
func (NameForms) Contains ¶
Contains is a thread-safe method that returns a collection slice element index integer and a presence-indicative boolean value based on a term search conducted within the receiver.
func (NameForms) Equal ¶
func (r NameForms) Equal(x NameFormCollection) bool
Equal performs a deep-equal between the receiver and the provided collection type.
func (NameForms) Get ¶
Get combines Contains and Index method executions to return an entry based on a term search conducted within the receiver.
func (NameForms) Index ¶
Index is a thread-safe method that returns the nth collection slice element if defined, else nil. This method supports use of negative indices which should be used with special care.
func (NameForms) IsZero ¶
IsZero returns a boolean value indicative of whether the receiver is considered empty or uninitialized.
func (NameForms) Len ¶
Len is a thread-safe method that returns the effective length of the receiver slice collection.
func (*NameForms) Set ¶
Set is a thread-safe append method that returns an error instance indicative of whether the append operation failed in some manner. Uniqueness is enforced for new elements based on Object Identifier and not the effective Name of the definition, if defined.
func (*NameForms) SetMacros ¶
SetMacros assigns the *Macros instance to the receiver, allowing subsequent OID resolution capabilities during the addition of new slice elements.
func (*NameForms) SetSpecifier ¶
SetSpecifier is a convenience method that executes the SetSpecifier method in iterative fashion for all definitions within the receiver.
func (*NameForms) SetUnmarshaler ¶
func (r *NameForms) SetUnmarshaler(fn DefinitionUnmarshaler)
SetUnmarshaler is a convenience method that executes the SetUnmarshaler method in iterative fashion for all definitions within the receiver.
type OID ¶
type OID []int
OID is a type alias for []int that describes an ASN.1 Object Identifier.
func NewOID ¶
NewOID returns an instance of OID based on the provided input variable x. Supported OID input types are []string, []int or string.
func (OID) Equal ¶
Equal returns a boolean value indicative of whether the receiver and x are equal.
type ObjectClass ¶
type ObjectClass struct { OID OID Name Name Description Description Obsolete bool SuperClass ObjectClassCollection Kind Kind Must AttributeTypeCollection May AttributeTypeCollection Extensions *Extensions // contains filtered or unexported fields }
ObjectClass conforms to the specifications of RFC4512 Section 4.1.1.
Example (ManualComposition) ¶
// This example demonstrates an ALTERNATIVE to // raw definition parsing, instead allowing any // given definition to be created from scratch // in a more object oriented fashion. // First, create a minimal subschema just to lookup // AttributeType instance required or permitted by // a given ObjectClass. Skip if you've already got // your own subschema instance to use. sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() // Create a new instance of *ObjectClass // and populate as needed. def := NewObjectClass() def.OID = NewOID(`1.3.6.1.4.1.56521.999.1.2.4.1`) def.Name = NewName(`genericExampleClass`, `classAltName`) def.Description = Description(`Generic example class`) def.Kind = Auxiliary // REQUIRED: choose ONE of Auxiliary, Structural or Abstract // Direct our new class to mandate the use of cn, o and mail // attribute types. Alter as needed. for _, must := range []string{`cn`, `o`, `mail`} { if at := sch.GetAttributeType(must); !at.IsZero() { def.Must.Set(at) } } // Direct our new class to allow the OPTIONAL use of c, description // givenName and sn attribute types. Alter as needed. for _, may := range []string{`c`, `description`, `givenName`, `sn`} { if at := sch.GetAttributeType(may); !at.IsZero() { def.May.Set(at) } } // Make sure validation checks return NO // errors before using your definition! if err := def.Validate(); err != nil { // handle your fatal error } // All checks pass! Use your new definition as needed!
Output:
func NewObjectClass ¶ added in v1.1.0
func NewObjectClass() *ObjectClass
NewObjectClass returns a newly initialized, yet effectively nil, instance of *ObjectClass.
Users generally do not need to execute this function unless an instance of the returned type will be manually populated (as opposed to parsing a raw text definition).
func (*ObjectClass) Equal ¶
func (r *ObjectClass) Equal(x any) (eq bool)
Equal performs a deep-equal between the receiver and the provided definition type.
Description text is ignored.
Example ¶
oc1 := &ObjectClass{ Name: NewName(`fakeName`), OID: NewOID(`1.3.6.1.4.1.56521.999.104.17.2.2.84`), Kind: Auxiliary, } oc2 := &ObjectClass{ Name: NewName(`fakeName`), OID: NewOID(`1.3.6.1.4.1.56521.999.104.17.2.2.81`), Kind: Structural, } fmt.Printf("%T instances are equal: %t\n", oc1, oc1.Equal(oc2))
Output: *schemax.ObjectClass instances are equal: false
func (*ObjectClass) Info ¶
func (r *ObjectClass) Info() []byte
Info returns the assigned informational byte slice instance stored within the receiver.
func (*ObjectClass) IsZero ¶
func (r *ObjectClass) IsZero() bool
IsZero returns a boolean value indicative of whether the receiver is considered empty or uninitialized.
Example ¶
oc := &ObjectClass{} fmt.Printf("%T is zero: %t\n", oc, oc.IsZero()) // Output *schemax.ObjectClass is zero: true
Output:
func (*ObjectClass) Map ¶
func (r *ObjectClass) Map() (def map[string][]string)
Map is a convenience method that returns a map[string][]string instance containing the effective contents of the receiver.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() sch.OCC = PopulateDefaultObjectClasses() myDef := `( 1.3.6.1.4.1.56521.999.104.17.3.71.3 NAME 'jessesClass' DESC 'This is an example ObjectClass definition' SUP top AUXILIARY MUST ( cn $ l $ o ) MAY ( description $ c ) X-ORIGIN 'Jesse Coretta' )` if err := sch.MarshalObjectClass(myDef); err != nil { panic(err) } jclass := sch.OCC.Get(`jessesClass`).Map() fmt.Printf("%T fields: %d\n", jclass, len(jclass))
Output: map[string][]string fields: 10
func (*ObjectClass) SetInfo ¶
func (r *ObjectClass) SetInfo(info []byte)
SetInfo assigns the byte slice to the receiver. This is a user-leveraged field intended to allow arbitrary information (documentation?) to be assigned to the definition.
func (*ObjectClass) SetSpecifier ¶
func (r *ObjectClass) SetSpecifier(spec string)
SetSpecifier assigns a string value to the receiver, useful for placement into configurations that require a type name (e.g.: objectclass). This will be displayed at the beginning of the definition value during the unmarshal or unsafe stringification process.
func (*ObjectClass) SetUnmarshaler ¶
func (r *ObjectClass) SetUnmarshaler(fn DefinitionUnmarshaler)
SetUnmarshaler assigns the provided DefinitionUnmarshaler signature value to the receiver. The provided function shall be executed during the unmarshal or unsafe stringification process.
func (ObjectClass) String ¶
func (r ObjectClass) String() (def string)
String is an unsafe convenience wrapper for Unmarshal(r). If an error is encountered, an empty string definition is returned. If reliability and error handling are important, use Unmarshal.
func (*ObjectClass) Type ¶
func (r *ObjectClass) Type() string
Type returns the formal name of the receiver in order to satisfy signature requirements of the Definition interface type.
func (*ObjectClass) Validate ¶
func (r *ObjectClass) Validate() (err error)
Validate returns an error that reflects any fatal condition observed regarding the receiver configuration.
type ObjectClassCollection ¶
type ObjectClassCollection interface { // Get returns the *ObjectClass instance retrieved as a result // of a term search, based on Name or OID. If no match is found, // nil is returned. Get(any) *ObjectClass // Index returns the *ObjectClass instance stored at the nth // index within the receiver, or nil. Index(int) *ObjectClass // Equal performs a deep-equal between the receiver and the // interface ObjectClassCollection provided. Equal(ObjectClassCollection) bool // Set returns an error instance based on an attempt to add // the provided *ObjectClass instance to the receiver. Set(*ObjectClass) error // Contains returns the index number and presence boolean that // reflects the result of a term search within the receiver. Contains(any) (int, bool) // String returns a properly-delimited sequence of string // values, either as a Name or OID, for the receiver type. String() string // Label returns the field name associated with the interface // types, or a zero string if no label is appropriate. Label() string // IsZero returns a boolean value indicative of whether the // receiver is considered zero, or undefined. IsZero() bool // Len returns an integer value indicative of the current // number of elements stored within the receiver. Len() int // SetSpecifier assigns a string value to all definitions within // the receiver. This value is used in cases where a definition // type name (e.g.: attributetype, objectclass, etc.) is required. // This value will be displayed at the beginning of the definition // value during the unmarshal or unsafe stringification process. SetSpecifier(string) // SetUnmarshaler assigns the provided DefinitionUnmarshaler // signature to all definitions within the receiver. The provided // function shall be executed during the unmarshal or unsafe // stringification process. SetUnmarshaler(DefinitionUnmarshaler) }
ObjectClassCollection describes all ObjectClasses-based types:
- *SuperiorObjectClasses
- *AuxiliaryObjectClasses
func NewAuxiliaryObjectClasses ¶
func NewAuxiliaryObjectClasses() ObjectClassCollection
NewAuxiliaryObjectClasses returns an initialized instance of AuxiliaryObjectClasses cast as an ObjectClassCollection.
Example ¶
auxs := NewAuxiliaryObjectClasses() fmt.Printf("%T is zero: %t\n", auxs, auxs.IsZero())
Output: *schemax.AuxiliaryObjectClasses is zero: true
func NewObjectClasses ¶
func NewObjectClasses() ObjectClassCollection
NewObjectClasses returns an initialized instance of ObjectClasses cast as an ObjectClassCollection.
Example ¶
ocm := NewObjectClasses() fmt.Printf("%T is zero: %t", ocm, ocm.IsZero())
Output: *schemax.ObjectClasses is zero: true
func NewSuperiorObjectClasses ¶
func NewSuperiorObjectClasses() ObjectClassCollection
NewSuperiorObjectClasses returns an initialized instance of SuperiorObjectClasses cast as an ObjectClassCollection.
Example ¶
sups := NewSuperiorObjectClasses() fmt.Printf("%T is zero: %t\n", sups, sups.IsZero())
Output: *schemax.SuperiorObjectClasses is zero: true
func PopulateDefaultObjectClasses ¶
func PopulateDefaultObjectClasses() ObjectClassCollection
PopulateDefaultObjectClasses returns a new auto-populated instance of ObjectClasses.
Within this structure are all of the following:
• Object classes from RFC2079 (imported from go-schemax/rfc2079)
• Object classes from RFC2307 (imported from go-schemax/rfc2307)
• Object classes from RFC4512 (imported from go-schemax/rfc4512)
• Object classes from RFC4519 (imported from go-schemax/rfc4519)
• Object classes from RFC4523 (imported from go-schemax/rfc4523)
• Object classes from RFC4524 (imported from go-schemax/rfc4524)
• Object classes from RFC3672 (imported from go-schemax/rfc3672)
type ObjectClasses ¶
type ObjectClasses struct {
// contains filtered or unexported fields
}
ObjectClasses is a thread-safe collection of *ObjectClass slice instances.
func (ObjectClasses) Contains ¶
func (r ObjectClasses) Contains(x any) (int, bool)
Contains is a thread-safe method that returns a collection slice element index integer and a presence-indicative boolean value based on a term search conducted within the receiver.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() sch.OCC = PopulateDefaultObjectClasses() _, found := sch.OCC.Contains(`account`) fmt.Printf("account ObjectClass exists: %t\n", found)
Output: account ObjectClass exists: true
func (ObjectClasses) Equal ¶
func (r ObjectClasses) Equal(x ObjectClassCollection) bool
Equal performs a deep-equal between the receiver and the provided collection type.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() sch.OCC = PopulateDefaultObjectClasses() otherOCC := NewObjectClasses() same := sch.OCC.Equal(otherOCC) fmt.Printf("%T instances are equal: %t\n", sch.OCC, same)
Output: *schemax.ObjectClasses instances are equal: false
func (ObjectClasses) Get ¶
func (r ObjectClasses) Get(x any) *ObjectClass
Get combines Contains and Index method executions to return an entry based on a term search conducted within the receiver.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() sch.OCC = PopulateDefaultObjectClasses() if class := sch.OCC.Get(`account`); !class.IsZero() { fmt.Printf("account OID: %s\n", class.OID) }
Output: account OID: 0.9.2342.19200300.100.4.5
func (ObjectClasses) Index ¶
func (r ObjectClasses) Index(idx int) *ObjectClass
Index is a thread-safe method that returns the nth collection slice element if defined, else nil. This method supports use of negative indices which should be used with special care.
func (*ObjectClasses) IsZero ¶
func (r *ObjectClasses) IsZero() bool
IsZero returns a boolean value indicative of whether the receiver is considered empty or uninitialized.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() sch.OCC = PopulateDefaultObjectClasses() isZero := sch.OCC.IsZero() fmt.Printf("%T is zero: %t\n", sch.OCC, isZero)
Output: *schemax.ObjectClasses is zero: false
func (ObjectClasses) Label ¶
func (r ObjectClasses) Label() string
Label returns the known label for the receiver, if one exists.
func (ObjectClasses) Len ¶
func (r ObjectClasses) Len() int
Len is a thread-safe method that returns the effective length of the receiver slice collection.
func (*ObjectClasses) Set ¶
func (r *ObjectClasses) Set(x *ObjectClass) error
Set is a thread-safe append method that returns an error instance indicative of whether the append operation failed in some manner. Uniqueness is enforced for new elements based on Object Identifier and not the effective Name of the definition, if defined.
func (*ObjectClasses) SetMacros ¶
func (r *ObjectClasses) SetMacros(macros *Macros)
SetMacros assigns the *Macros instance to the receiver, allowing subsequent OID resolution capabilities during the addition of new slice elements.
func (*ObjectClasses) SetSpecifier ¶
func (r *ObjectClasses) SetSpecifier(spec string)
SetSpecifier is a convenience method that executes the SetSpecifier method in iterative fashion for all definitions within the receiver.
func (*ObjectClasses) SetUnmarshaler ¶
func (r *ObjectClasses) SetUnmarshaler(fn DefinitionUnmarshaler)
SetUnmarshaler is a convenience method that executes the SetUnmarshaler method in iterative fashion for all definitions within the receiver.
func (ObjectClasses) String ¶
func (r ObjectClasses) String() string
String returns a properly-delimited sequence of string values, either as a Name or OID, for the receiver type.
type Ordering ¶
type Ordering struct {
*MatchingRule
}
Ordering circumscribes an embedded pointer to an instance of *MatchingRule. This type alias is intended for use solely within instances of AttributeType via its "Ordering" struct field.
type PermittedAttributeTypes ¶
type PermittedAttributeTypes struct {
*AttributeTypes
}
PermittedAttributeTypes contains an embedded instance of *AttributeTypes. This alias type reflects the MAY fields of a dITContentRule or objectClass definitions.
func (PermittedAttributeTypes) Label ¶
func (r PermittedAttributeTypes) Label() string
Label returns the known label for the receiver, if one exists.
Example ¶
may := PermittedAttributeTypes{} lab := may.Label() fmt.Printf("%T label: %s (len:%d)\n", may, lab, len(lab))
Output: schemax.PermittedAttributeTypes label: MAY (len:3)
func (PermittedAttributeTypes) String ¶
func (r PermittedAttributeTypes) String() string
String returns a properly-delimited sequence of string values, either as a Name or OID, for the receiver type.
type ProhibitedAttributeTypes ¶
type ProhibitedAttributeTypes struct {
*AttributeTypes
}
ProhibitedAttributeTypes contains an embedded instance of *AttributeTypes. This alias type reflects the NOT field of a dITContentRule definition.
func (ProhibitedAttributeTypes) Label ¶
func (r ProhibitedAttributeTypes) Label() string
Label returns the known label for the receiver, if one exists.
Example ¶
not := ProhibitedAttributeTypes{} lab := not.Label() fmt.Printf("%T label: %s (len:%d)\n", not, lab, len(lab))
Output: schemax.ProhibitedAttributeTypes label: NOT (len:3)
func (ProhibitedAttributeTypes) String ¶
func (r ProhibitedAttributeTypes) String() string
String returns a properly-delimited sequence of string values, either as a Name or OID, for the receiver type.
type RequiredAttributeTypes ¶
type RequiredAttributeTypes struct {
*AttributeTypes
}
RequiredAttributeTypes contains an embedded instance of *AttributeTypes. This alias type reflects the MUST fields of a dITContentRule or objectClass definitions.
func (RequiredAttributeTypes) Label ¶
func (r RequiredAttributeTypes) Label() string
Label returns the known label for the receiver, if one exists.
Example ¶
must := RequiredAttributeTypes{} lab := must.Label() fmt.Printf("%T label: %s (len:%d)\n", must, lab, len(lab))
Output: schemax.RequiredAttributeTypes label: MUST (len:4)
func (RequiredAttributeTypes) String ¶
func (r RequiredAttributeTypes) String() string
String returns a properly-delimited sequence of string values, either as a Name or OID, for the receiver type.
type RuleID ¶
type RuleID uint
RuleID describes a numerical identifier for an instance of DITStructureRule.
func NewRuleID ¶
NewRuleID returns a new instance of *RuleID, intended for assignment to an instance of *DITStructureRule.
func (RuleID) Equal ¶
Equal returns a boolean value indicative of whether the provided value is numerically equal to the receiver.
type StructuralObjectClass ¶
type StructuralObjectClass struct {
*ObjectClass
}
StructuralObjectClass is a type alias of *ObjectClass intended for use solely within instances of NameForm within its "OC" field.
func (StructuralObjectClass) Label ¶
func (r StructuralObjectClass) Label() string
Label returns the known label for the receiver, if one exists.
type Subschema ¶
type Subschema struct { DN string // often "cn=schema" or "cn=subschema", varies per imp. LSC LDAPSyntaxCollection // LDAP Syntaxes MRC MatchingRuleCollection // Matching Rules ATC AttributeTypeCollection // Attribute Types MRUC MatchingRuleUseCollection // Matching Rule "Uses" OCC ObjectClassCollection // Object Classes DCRC DITContentRuleCollection // DIT Content Rules NFC NameFormCollection // Name Forms DSRC DITStructureRuleCollection // DIT Structure Rules }
Subschema provides high-level definition management, storage of all definitions of schemata and convenient method wrappers.
The first field of this type, "DN", contains a string representation of the appropriate subschema distinguished name. Oftentimes, this will be something like "cn=schema", or "cn=subschema" but may vary between directory implementations.
All remaining fields within this type are based on the collection (slice) types defined in this package. For example, Subschema "NFC" field is of the NameForms Collection type, and is intended to store all successfully-parsed "nameForm" definitions.
The user must initialize these map-based fields before use, whether they do so themselves manually, OR by use of a suitable "populator function", such as the PopulateDefaultLDAPSyntaxes() function to populate the "LSC" field.
The purpose of this type is to centralize all of the relevant slices that the user would otherwise have to manage individually. This is useful for portability reasons, and allows an entire library of X.501 schema definitions to be stored within a single object.
This type also provides high-level oversight of what would otherwise be isolated low-level operations that may or may not be invalid. For example, when operating in a purely low-level fashion (without the use of *Subschema), there is nothing stopping a user from adding a so-called "RequiredAttributeTypes" slice member to a "ProhibitedAttributeTypes" slice. Each of those slices is thoroughly unaware of the other. However, when conducting this operation via a convenient method extended by *Subschema, additional correlative checks can (and will!) be conducted to avoid such invalid actions.
Overall, use of *Subschema makes generalized use of this package slightly easier but is NOT necessarily required in all situations.
func NewSubschema ¶
func NewSubschema() (s *Subschema)
NewSubschema returns a partially-initialized instance of *Subschema.
Example ¶
sch := NewSubschema() fmt.Printf("%T\n", sch)
Output: *schemax.Subschema
func (*Subschema) GetAttributeType ¶
func (r *Subschema) GetAttributeType(x string) *AttributeType
GetAttributeType is a convenient wrapper method for AttributeType.Get. Using this method, the user need not worry about providing an Aliases manually.
func (Subschema) GetDITContentRule ¶
func (r Subschema) GetDITContentRule(x string) *DITContentRule
GetDITContentRule is a convenient wrapper method for DITContentRules.Get. Using this method, the user need not worry about providing an Aliases manually.
func (Subschema) GetDITStructureRule ¶
func (r Subschema) GetDITStructureRule(x string) *DITStructureRule
GetDITStructureRule is a convenient wrapper method for DITStructureRules.Get.
func (Subschema) GetLDAPSyntax ¶
func (r Subschema) GetLDAPSyntax(x string) *LDAPSyntax
GetLDAPSyntax is a convenient wrapper method for LDAPSyntaxes.Get. Using this method, the user need not worry about providing an Aliases manually.
func (Subschema) GetMatchingRule ¶
func (r Subschema) GetMatchingRule(x string) *MatchingRule
GetMatchingRule is a convenient wrapper method for MatchingRule.Get. Using this method, the user need not worry about providing an Aliases manually.
func (Subschema) GetMatchingRuleUse ¶
func (r Subschema) GetMatchingRuleUse(x string) *MatchingRuleUse
GetMatchingRuleUse is a convenient wrapper method for MatchingRuleUses.Get. Using this method, the user need not worry about providing an Aliases manually.
func (Subschema) GetNameForm ¶
GetNameForm is a convenient wrapper method for NameForms.Get. Using this method, the user need not worry about providing an Aliases manually.
func (Subschema) GetObjectClass ¶
func (r Subschema) GetObjectClass(x string) *ObjectClass
GetAttributeType is a convenient wrapper method for AttributeType.Get. Using this method, the user need not worry about providing an Aliases manually.
func (*Subschema) MarshalAttributeType ¶
MarshalAttributeType will attempt to perform a marshal operation upon the provided string definition under the assumption that it represents an Attribute Type. An error is returned in the event that a parsing failure occurs in any way. No *AttributeType instance is stored in such an event.
In the event a successful marshal, a new *AttributeType instance is catalogued within the Subschema.ATC (AttributeTypes) struct field.
This method requires the complete population of the following collections before-hand:
• LDAPSyntaxes (Subschema.LSC)
• MatchingRules (Subschema.MRC)
• AttributeTypes (Subschema.ATC, if a particular definition a sub type of another type)
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = NewAttributeTypes() myDef := `( 1.3.6.1.4.1.56521.999.104.17.2.1.10 NAME ( 'jessesNewAttr' 'jesseAltName' ) DESC 'This is an example AttributeType definition' OBSOLETE SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 EQUALITY caseIgnoreMatch X-ORIGIN 'Jesse Coretta' )` if err := sch.MarshalAttributeType(myDef); err != nil { panic(err) } jattr := sch.ATC.Get(`jessesNewAttr`) if !jattr.IsZero() { fmt.Printf("%T.OID: %s\n", jattr, jattr.OID) }
Output: *schemax.AttributeType.OID: 1.3.6.1.4.1.56521.999.104.17.2.1.10
func (*Subschema) MarshalDITContentRule ¶
MarshalDITContentRule will attempt to perform a marshal operation upon the provided string definition under the assumption that it represents a DIT Content Rule. An error is returned in the event that a parsing failure occurs in any way. No *DITContentRule instance is stored in such an event.
In the event a successful marshal, a new *DITContentRule instance is catalogued within the Subschema.DCRC (DITContentRules) struct field.
Note that the OID assigned to the raw DIT Content Rule definition MUST correlate to the registered OID of a STRUCTURAL *ObjectClass instance.
This method requires the complete population of the following collections before-hand:
• AttributeTypes (Subschema.ATC)
• ObjectClasses (Subschema.OCC)
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() sch.OCC = PopulateDefaultObjectClasses() dcr := `( 0.9.2342.19200300.100.4.5 NAME 'accountContentRule' AUX ( posixAccount $ shadowAccount ) MUST uid MAY description NOT gecos )` if err := sch.MarshalDITContentRule(dcr); err != nil { panic(err) } aDCR := sch.DCRC.Get(`accountContentRule`) if !aDCR.IsZero() { fmt.Printf("%T.OID: %s\n", aDCR, aDCR.OID) }
Output: *schemax.DITContentRule.OID: 0.9.2342.19200300.100.4.5
func (*Subschema) MarshalDITStructureRule ¶
MarshalDITStructureRule will attempt to perform a marshal operation upon the provided string definition under the assumption that it represents a DIT Structure Rule. An error is returned in the event that a parsing failure occurs in any way. No *DITStructureRule instance is stored in such an event.
In the event a successful marshal, a new *DITStructureRule instance is catalogued within the Subschema.DSRC (DITStructureRules) struct field.
This method requires the complete population of the following collections before-hand:
• NameForms (Subschema.NFC)
• DITStructureRules (Subschema.DSRC, if superior DIT Structure Rules are referenced)
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() sch.OCC = PopulateDefaultObjectClasses() nf := `( 1.3.6.1.4.1.56521.999.104.17.2.16.4 NAME 'jesseNameForm' DESC 'this is an example Name Form definition' OC account MUST ( cn $ o $ uid ) MAY ( description $ l ) X-ORIGIN 'Jesse Coretta' )` if err := sch.MarshalNameForm(nf); err != nil { panic(err) } dsr := `( 0 NAME 'jesseDSR' DESC 'this is an example DIT Structure Rule' FORM jesseNameForm X-ORIGIN 'Jesse Coretta' )` if err := sch.MarshalDITStructureRule(dsr); err != nil { panic(err) } jdsr := sch.DSRC.Get(`jesseDSR`) if !jdsr.IsZero() { fmt.Printf("%T.ID: %d\n", jdsr, jdsr.ID) }
Output: *schemax.DITStructureRule.ID: 0
func (*Subschema) MarshalLDAPSyntax ¶
MarshalLDAPSyntax will attempt to perform a marshal operation upon the provided string definition under the assumption that it represents an LDAP Syntax. An error is returned in the event that a parsing failure occurs in any way. No *LDAPSyntax instance is stored in such an event.
In the event a successful marshal, a new *LDAPSyntax instance is catalogued within the Subschema.LSC (LDAPSyntaxes) struct field.
It is important to note that it is unusual for end users to "invent" new LDAP syntaxes. Most directory implementations do not allow the designation of such definitions arbitrarily. As such, this method (and those that are similar) is intended only for the marshaling and/or registration of "official LDAP syntaxes" (i.e.: those that are defined in an accepted RFC or Internet-Draft).
Users are strongly advised to simply set the Subschema.LSC field using the DefaultLDAPSyntaxes global variable.
LDAP Syntaxes are wholly independent in the referential sense. They are dependent upon no other schema definition type, thus they should ALWAYS be populated BEFORE all other definition types.
Example ¶
sch := NewSubschema() ls := `( 1.3.6.1.4.1.1466.115.121.1.2 DESC 'Access Point' X-ORIGIN 'RFC4517' )` if err := sch.MarshalLDAPSyntax(ls); err != nil { panic(err) } ap := sch.LSC.Get(`Access Point`) if !ap.IsZero() { fmt.Printf("%T.OID: %s (%s)\n", ap, ap.OID, ap.Description) }
Output: *schemax.LDAPSyntax.OID: 1.3.6.1.4.1.1466.115.121.1.2 ('Access Point')
func (*Subschema) MarshalMatchingRule ¶
MarshalMatchingRule will attempt to perform a marshal operation upon the provided string definition under the assumption that it represents an Matching Rule. An error is returned in the event that a parsing failure occurs in any way. No *MatchingRule instance is stored in such an event.
In the event a successful marshal, a new *MatchingRule instance is catalogued within the Subschema.MRC (MatchingRules) struct field.
It is important to note that it is unusual for end users to "invent" new matching rules. Most directory implementations do not allow the designation of such definitions arbitrarily. As such, this method (and those that are similar) is intended only for the marshaling and/or registration of "official matching rules" (i.e.: those that are defined in an accepted RFC or Internet-Draft).
Users are strongly advised to simply set the Subschema.MRC field using the DefaultMatchingRules global variable.
This method requires the complete population of the LDAPSyntaxes (Subschema.LSC) beforehand.
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = NewMatchingRules() mr := `( 1.3.6.1.4.1.1466.109.114.3 NAME 'caseIgnoreIA5SubstringsMatch' SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 X-ORIGIN 'RFC4517' )` if err := sch.MarshalMatchingRule(mr); err != nil { panic(err) } mrd := sch.MRC.Get(`caseIgnoreIA5SubstringsMatch`) if !mrd.IsZero() { fmt.Printf("%T.OID: %s\n", mrd, mrd.OID) }
Output: *schemax.MatchingRule.OID: 1.3.6.1.4.1.1466.109.114.3
func (*Subschema) MarshalNameForm ¶
MarshalNameForm will attempt to perform a marshal operation upon the provided string definition under the assumption that it represents a Name Form. An error is returned in the event that a parsing failure occurs in any way. No *NameForm instance is stored in such an event.
In the event a successful marshal, a new *NameForm instance is catalogued within the Subschema.NFC (NameForms) struct field.
This method requires the complete population of the following collections before-hand:
• AttributeTypes (Subschema.ATC)
• ObjectClasses (Subschema.OCC)
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() sch.OCC = PopulateDefaultObjectClasses() myDef := `( 1.3.6.1.4.1.56521.999.104.17.2.16.4 NAME 'jesseNameForm' DESC 'this is an example Name Form definition' OC account MUST ( cn $ o $ uid ) MAY ( description $ l ) X-ORIGIN 'Jesse Coretta' )` if err := sch.MarshalNameForm(myDef); err != nil { panic(err) } jnf := sch.NFC.Get(`jesseNameForm`) if !jnf.IsZero() { fmt.Printf("%T.OID: %s\n", jnf, jnf.OID) }
Output: *schemax.NameForm.OID: 1.3.6.1.4.1.56521.999.104.17.2.16.4
func (*Subschema) MarshalObjectClass ¶
MarshalObjectClass will attempt to perform a marshal operation upon the provided string definition under the assumption that it represents an Object Class. An error is returned in the event that a parsing failure occurs in any way. No *ObjectClass instance is stored in such an event.
In the event a successful marshal, a new *ObjectClass instance is catalogued within the Subschema.OCC (ObjectClass) struct field.
This method requires the complete population of the following collections before-hand:
• AttributeTypes (Subschema.ATC) beforehand
• ObjectClasses (Subschema.OCC, if a particular definition a sub class one or more other classes)
Example ¶
sch := NewSubschema() sch.LSC = PopulateDefaultLDAPSyntaxes() sch.MRC = PopulateDefaultMatchingRules() sch.ATC = PopulateDefaultAttributeTypes() sch.OCC = PopulateDefaultObjectClasses() myDef := `( 1.3.6.1.4.1.56521.999.104.17.2.2.91 NAME ( 'jesseOC' 'specialJesseClass' ) DESC 'This is an example ObjectClass definition' SUP account AUXILIARY MUST ( sn $ givenName $ carLicense ) MAY ( description $ mobile ) X-ORIGIN 'Jesse Coretta' )` if err := sch.MarshalObjectClass(myDef); err != nil { panic(err) } joc := sch.OCC.Get(`jesseOC`) if !joc.IsZero() { fmt.Printf("%T.OID: %s\n", joc, joc.OID) }
Output: *schemax.ObjectClass.OID: 1.3.6.1.4.1.56521.999.104.17.2.2.91
func (*Subschema) PopulateDefaultAttributeTypes ¶
func (r *Subschema) PopulateDefaultAttributeTypes()
PopulateDefaultAttributeTypes is a Subschema-housed convenience method for PopulateDefaultAttributeTypes, and includes internal indexing to maintain proper ordering of definitions.
func (*Subschema) PopulateDefaultLDAPSyntaxes ¶
func (r *Subschema) PopulateDefaultLDAPSyntaxes()
PopulateDefaultLDAPSyntaxes is a Subschema-housed convenience method for PopulateDefaultLDAPSyntaxes, and includes internal indexing to maintain proper ordering of definitions.
func (*Subschema) PopulateDefaultMatchingRules ¶
func (r *Subschema) PopulateDefaultMatchingRules()
PopulateDefaultMatchingRules is a Subschema-housed convenience method for PopulateDefaultMatchingRules, and includes internal indexing to maintain proper ordering of definitions.
func (*Subschema) PopulateDefaultObjectClasses ¶
func (r *Subschema) PopulateDefaultObjectClasses()
PopulateDefaultObjectClasses is a Subschema-housed convenience method for PopulateDefaultObjectClasses, and includes internal indexing to maintain proper ordering of definitions.
func (*Subschema) SetAttributeType ¶
func (r *Subschema) SetAttributeType(x *AttributeType) (ok bool)
Set will assign x to the receiver, storing the content within the appropriate collection. A boolean value is returned indicative of success.
func (*Subschema) SetDITContentRule ¶
func (r *Subschema) SetDITContentRule(x *DITContentRule) (ok bool)
Set will assign x to the receiver, storing the content within the appropriate collection. A boolean value is returned indicative of success.
func (*Subschema) SetDITStructureRule ¶
func (r *Subschema) SetDITStructureRule(x *DITStructureRule) (ok bool)
Set will assign x to the receiver, storing the content within the appropriate collection. A boolean value is returned indicative of success.
func (*Subschema) SetLDAPSyntax ¶
func (r *Subschema) SetLDAPSyntax(x *LDAPSyntax) (ok bool)
Set will assign x to the receiver, storing the content within the appropriate collection. A boolean value is returned indicative of success.
func (*Subschema) SetMatchingRule ¶
func (r *Subschema) SetMatchingRule(x *MatchingRule) (ok bool)
Set will assign x to the receiver, storing the content within the appropriate collection. A boolean value is returned indicative of success.
func (*Subschema) SetMatchingRuleUse ¶
func (r *Subschema) SetMatchingRuleUse(x *MatchingRuleUse) (ok bool)
Set will assign x to the receiver, storing the content within the appropriate collection. A boolean value is returned indicative of success.
func (*Subschema) SetNameForm ¶
Set will assign x to the receiver, storing the content within the appropriate collection. A boolean value is returned indicative of success.
func (*Subschema) SetObjectClass ¶
func (r *Subschema) SetObjectClass(x *ObjectClass) (ok bool)
Set will assign x to the receiver, storing the content within the appropriate collection. A boolean value is returned indicative of success.
type Substring ¶
type Substring struct {
*MatchingRule
}
Substring circumscribes an embedded pointer to an instance of *MatchingRule. This type alias is intended for use solely within instances of AttributeType via its "Substring" struct field.
type SuperiorAttributeType ¶
type SuperiorAttributeType struct {
*AttributeType
}
SuperiorAttributeType contains an embedded instance of *AttributeType. This alias type reflects the SUP field of an attributeType definition.
func (SuperiorAttributeType) IsZero ¶
func (r SuperiorAttributeType) IsZero() bool
IsZero returns a boolean value indicative of whether the receiver is considered empty or uninitialized.
func (SuperiorAttributeType) Label ¶
func (r SuperiorAttributeType) Label() string
Label returns the known label for the receiver, if one exists.
Example ¶
sup := SuperiorAttributeType{} lab := sup.Label() fmt.Printf("%T label: %s (len:%d)\n", sup, lab, len(lab))
Output: schemax.SuperiorAttributeType label: SUP (len:3)
type SuperiorDITStructureRules ¶
type SuperiorDITStructureRules struct {
*DITStructureRules
}
SuperiorDITStructureRules contains an embedded instance of *DITStructureRules. This alias type reflects the SUP field of an dITStructureRule definition.
func (SuperiorDITStructureRules) Label ¶
func (r SuperiorDITStructureRules) Label() string
Label returns the known label for the receiver, if one exists.
Example ¶
sups := SuperiorDITStructureRules{} lab := sups.Label() fmt.Printf("%T label: %s (len:%d)\n", sups, lab, len(lab))
Output: schemax.SuperiorDITStructureRules label: SUP (len:3)
func (SuperiorDITStructureRules) String ¶
func (r SuperiorDITStructureRules) String() string
String is a stringer method used to return the properly-delimited and formatted series of attributeType name or OID definitions.
type SuperiorObjectClasses ¶
type SuperiorObjectClasses struct {
*ObjectClasses
}
SuperiorObjectClasses contains an embedded *ObjectClasses instance. This type alias is meant to reside within the SUP field of an objectClass definition.
func (SuperiorObjectClasses) Label ¶
func (r SuperiorObjectClasses) Label() string
Label returns the known label for the receiver, if one exists.
Example ¶
sups := SuperiorObjectClasses{} lab := sups.Label() fmt.Printf("%T label: %s (len:%d)\n", sups, lab, len(lab))
Output: schemax.SuperiorObjectClasses label: SUP (len:3)
func (SuperiorObjectClasses) String ¶
func (r SuperiorObjectClasses) String() string
String returns a properly-delimited sequence of string values, either as a Name or OID, for the receiver type.
type Usage ¶
type Usage uint8
Usage describes the intended usage of an AttributeType definition as a single text value. This can be one of four constant values, the first of which (userApplication) is implied in the absence of any other value and is not necessary to reveal in such a case.