summaryrefslogtreecommitdiffstats
path: root/ldap.go
diff options
context:
space:
mode:
authorned <ned@appliedtrust.com>2014-11-23 20:03:05 +0100
committerned <ned@appliedtrust.com>2014-11-23 20:03:05 +0100
commitc43d537d5bb0eeb491153b00cdefcb54a6178187 (patch)
tree45187fde4a720d3f53d13ec45ac4fea8e27356e4 /ldap.go
parentLDAP server support (diff)
downloadldap-c43d537d5bb0eeb491153b00cdefcb54a6178187.tar
ldap-c43d537d5bb0eeb491153b00cdefcb54a6178187.tar.gz
ldap-c43d537d5bb0eeb491153b00cdefcb54a6178187.tar.bz2
ldap-c43d537d5bb0eeb491153b00cdefcb54a6178187.tar.lz
ldap-c43d537d5bb0eeb491153b00cdefcb54a6178187.tar.xz
ldap-c43d537d5bb0eeb491153b00cdefcb54a6178187.tar.zst
ldap-c43d537d5bb0eeb491153b00cdefcb54a6178187.zip
Diffstat (limited to '')
-rw-r--r--ldap.go44
1 files changed, 38 insertions, 6 deletions
diff --git a/ldap.go b/ldap.go
index 42c50d6..e6d6d52 100644
--- a/ldap.go
+++ b/ldap.go
@@ -107,7 +107,7 @@ const (
ErrorDebugging = 203
)
-var LDAPResultCodeMap = map[uint8]string{
+var LDAPResultCodeMap = map[LDAPResultCode]string{
LDAPResultSuccess: "Success",
LDAPResultOperationsError: "Operations Error",
LDAPResultProtocolError: "Protocol Error",
@@ -155,6 +155,38 @@ const (
LDAPBindAuthSASL = 3
)
+type LDAPResultCode uint8
+
+type Attribute struct {
+ attrType string
+ attrVals []string
+}
+type AddRequest struct {
+ dn string
+ attributes []Attribute
+}
+type DeleteRequest struct {
+ dn string
+}
+type ModifyDNRequest struct {
+ dn string
+ newrdn string
+ deleteoldrdn bool
+ newSuperior string
+}
+type AttributeValueAssertion struct {
+ attributeDesc string
+ assertionValue string
+}
+type CompareRequest struct {
+ dn string
+ ava []AttributeValueAssertion
+}
+type ExtendedRequest struct {
+ requestName string
+ requestValue string
+}
+
// Adds descriptions to an LDAP Response packet for debugging
func addLDAPDescriptions(packet *ber.Packet) (err error) {
defer func() {
@@ -259,7 +291,7 @@ func addRequestDescriptions(packet *ber.Packet) {
func addDefaultLDAPResponseDescriptions(packet *ber.Packet) {
resultCode := packet.Children[1].Children[0].Value.(uint64)
- packet.Children[1].Children[0].Description = "Result Code (" + LDAPResultCodeMap[uint8(resultCode)] + ")"
+ packet.Children[1].Children[0].Description = "Result Code (" + LDAPResultCodeMap[LDAPResultCode(resultCode)] + ")"
packet.Children[1].Children[1].Description = "Matched DN"
packet.Children[1].Children[2].Description = "Error Message"
if len(packet.Children[1].Children) > 3 {
@@ -285,22 +317,22 @@ func DebugBinaryFile(fileName string) error {
type Error struct {
Err error
- ResultCode uint8
+ ResultCode LDAPResultCode
}
func (e *Error) Error() string {
return fmt.Sprintf("LDAP Result Code %d %q: %s", e.ResultCode, LDAPResultCodeMap[e.ResultCode], e.Err.Error())
}
-func NewError(resultCode uint8, err error) error {
+func NewError(resultCode LDAPResultCode, err error) error {
return &Error{ResultCode: resultCode, Err: err}
}
-func getLDAPResultCode(packet *ber.Packet) (code uint8, description string) {
+func getLDAPResultCode(packet *ber.Packet) (code LDAPResultCode, description string) {
if len(packet.Children) >= 2 {
response := packet.Children[1]
if response.ClassType == ber.ClassApplication && response.TagType == ber.TypeConstructed && len(response.Children) == 3 {
- return uint8(response.Children[0].Value.(uint64)), response.Children[2].Value.(string)
+ return LDAPResultCode(response.Children[0].Value.(uint64)), response.Children[2].Value.(string)
}
}