build(deps): bump github.com/go-ldap/ldap/v3 from 3.4.11 to 3.4.12

Bumps [github.com/go-ldap/ldap/v3](https://github.com/go-ldap/ldap) from 3.4.11 to 3.4.12.
- [Release notes](https://github.com/go-ldap/ldap/releases)
- [Commits](https://github.com/go-ldap/ldap/compare/v3.4.11...v3.4.12)

---
updated-dependencies:
- dependency-name: github.com/go-ldap/ldap/v3
  dependency-version: 3.4.12
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2025-10-06 13:45:34 +00:00
committed by Ralf Haferkamp
parent 2fba3c5cdd
commit 8b35fa46f2
8 changed files with 251 additions and 54 deletions

2
go.mod
View File

@@ -23,7 +23,7 @@ require (
github.com/go-chi/chi/v5 v5.2.3
github.com/go-chi/render v1.0.3
github.com/go-jose/go-jose/v3 v3.0.4
github.com/go-ldap/ldap/v3 v3.4.11
github.com/go-ldap/ldap/v3 v3.4.12
github.com/go-ldap/ldif v0.0.0-20200320164324-fd88d9b715b3
github.com/go-micro/plugins/v4/client/grpc v1.2.1
github.com/go-micro/plugins/v4/logger/zerolog v1.2.0

8
go.sum
View File

@@ -108,8 +108,8 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE=
github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa h1:LHTHcTQiSGT7VVbI0o4wBRNQIgn917usHWOd6VAffYI=
github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa/go.mod h1:cEWa1LVoE5KvSD9ONXsZrj0z6KqySlCCNKHlLzbqAt4=
github.com/alexbrainman/sspi v0.0.0-20250919150558-7d374ff0d59e h1:4dAU9FXIyQktpoUAgOJK3OTFc/xug0PCXYCqU0FgDKI=
github.com/alexbrainman/sspi v0.0.0-20250919150558-7d374ff0d59e/go.mod h1:cEWa1LVoE5KvSD9ONXsZrj0z6KqySlCCNKHlLzbqAt4=
github.com/alexedwards/argon2id v1.0.0 h1:wJzDx66hqWX7siL/SRUmgz3F8YMrd/nfX/xHHcQQP0w=
github.com/alexedwards/argon2id v1.0.0/go.mod h1:tYKkqIjzXvZdzPvADMWOEZ+l6+BD6CtBXMj5fnJppiw=
github.com/aliyun/alibaba-cloud-sdk-go v1.61.976/go.mod h1:pUKYbK5JQ+1Dfxk80P0qxGqe5dkxDoabbZS7zOcouyA=
@@ -403,8 +403,8 @@ github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBj
github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU=
github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
github.com/go-ldap/ldap/v3 v3.1.7/go.mod h1:5Zun81jBTabRaI8lzN7E1JjyEl1g6zI6u9pd8luAK4Q=
github.com/go-ldap/ldap/v3 v3.4.11 h1:4k0Yxweg+a3OyBLjdYn5OKglv18JNvfDykSoI8bW0gU=
github.com/go-ldap/ldap/v3 v3.4.11/go.mod h1:bY7t0FLK8OAVpp/vV6sSlpz3EQDGcQwc8pF0ujLgKvM=
github.com/go-ldap/ldap/v3 v3.4.12 h1:1b81mv7MagXZ7+1r7cLTWmyuTqVqdwbtJSjC0DAp9s4=
github.com/go-ldap/ldap/v3 v3.4.12/go.mod h1:+SPAGcTtOfmGsCb3h1RFiq4xpp4N636G75OEace8lNo=
github.com/go-ldap/ldif v0.0.0-20200320164324-fd88d9b715b3 h1:sfz1YppV05y4sYaW7kXZtrocU/+vimnIWt4cxAYh7+o=
github.com/go-ldap/ldif v0.0.0-20200320164324-fd88d9b715b3/go.mod h1:ZXFhGda43Z2TVbfGZefXyMJzsDHhCh0go3bZUcwTx7o=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=

View File

@@ -1,7 +1,9 @@
package ldap
import (
"errors"
"fmt"
ber "github.com/go-asn1-ber/asn1-ber"
)
@@ -66,6 +68,10 @@ func NewAddRequest(dn string, controls []Control) *AddRequest {
// Add performs the given AddRequest
func (l *Conn) Add(addRequest *AddRequest) error {
if addRequest == nil {
return NewError(ErrorNetwork, errors.New("AddRequest cannot be nil"))
}
msgCtx, err := l.doRequest(addRequest)
if err != nil {
return err

View File

@@ -29,14 +29,86 @@ const (
// ControlTypeServerSideSorting - https://www.ietf.org/rfc/rfc2891.txt
ControlTypeServerSideSortingResult = "1.2.840.113556.1.4.474"
// ControlTypeMicrosoftNotification - https://msdn.microsoft.com/en-us/library/aa366983(v=vs.85).aspx
ControlTypeMicrosoftNotification = "1.2.840.113556.1.4.528"
// ControlTypeMicrosoftShowDeleted - https://msdn.microsoft.com/en-us/library/aa366989(v=vs.85).aspx
ControlTypeMicrosoftShowDeleted = "1.2.840.113556.1.4.417"
// ControlTypeMicrosoftServerLinkTTL - https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/f4f523a8-abc0-4b3a-a471-6b2fef135481?redirectedfrom=MSDN
ControlTypeMicrosoftServerLinkTTL = "1.2.840.113556.1.4.2309"
// ControlTypeDirSync - Active Directory DirSync - https://msdn.microsoft.com/en-us/library/aa366978(v=vs.85).aspx
// ControlTypeMicrosoftPagedResults - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftPagedResults = "1.2.840.113556.1.4.319"
// ControlTypeMicrosoftCrossDomainMoveTarget - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftCrossDomainMoveTarget = "1.2.840.113556.1.4.521"
// ControlTypeDirSync - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeDirSync = "1.2.840.113556.1.4.841"
// ControlTypeMicrosoftDomainScope - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftDomainScope = "1.2.840.113556.1.4.1339"
// ControlTypeMicrosoftExtendedDN - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftExtendedDN = "1.2.840.113556.1.4.529"
// ControlTypeMicrosoftGetStats - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftGetStats = "1.2.840.113556.1.4.970"
// ControlTypeMicrosoftLazyCommit - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftLazyCommit = "1.2.840.113556.1.4.619"
// ControlTypeMicrosoftPermissiveModify - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftPermissiveModify = "1.2.840.113556.1.4.1413"
// ControlTypeMicrosoftNotification - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftNotification = "1.2.840.113556.1.4.528"
// ControlTypeMicrosoftRespSort - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftRespSort = "1.2.840.113556.1.4.474"
// ControlTypeMicrosoftSDFlags - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftSDFlags = "1.2.840.113556.1.4.801"
// ControlTypeMicrosoftSearchOptions - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftSearchOptions = "1.2.840.113556.1.4.1340"
// ControlTypeMicrosoftSort - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftSort = "1.2.840.113556.1.4.473"
// ControlTypeMicrosoftShowDeleted - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftShowDeleted = "1.2.840.113556.1.4.417"
// ControlTypeMicrosoftTreeDelete - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftTreeDelete = "1.2.840.113556.1.4.805"
// ControlTypeMicrosoftVerifyName - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftVerifyName = "1.2.840.113556.1.4.1338"
// ControlTypeVLVRequest - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeVLVRequest = "2.16.840.1.113730.3.4.9"
// ControlTypeVLVResponse - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeVLVResponse = "2.16.840.1.113730.3.4.10"
// ControlTypeMicrosoftASQ - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftASQ = "1.2.840.113556.1.4.1504"
// ControlTypeMicrosoftQuotaControl - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftQuotaControl = "1.2.840.113556.1.4.1852"
// ControlTypeMicrosoftRangeOption - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftRangeOption = "1.2.840.113556.1.4.802"
// ControlTypeMicrosoftShutdownNotify - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftShutdownNotify = "1.2.840.113556.1.4.1907"
// ControlTypeMicrosoftForceUpdate - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftForceUpdate = "1.2.840.113556.1.4.1974"
// ControlTypeMicrosoftRangeRetrievalNoErr - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftRangeRetrievalNoErr = "1.2.840.113556.1.4.1948"
// ControlTypeMicrosoftRODCDCPromo - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftRODCDCPromo = "1.2.840.113556.1.4.1341"
// ControlTypeMicrosoftDNInput - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftDNInput = "1.2.840.113556.1.4.2026"
// ControlTypeMicrosoftShowDeactivatedLink - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftShowDeactivatedLink = "1.2.840.113556.1.4.2065"
// ControlTypeMicrosoftShowRecycled - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftShowRecycled = "1.2.840.113556.1.4.2064"
// ControlTypeMicrosoftPolicyHintsDeprecated - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftPolicyHintsDeprecated = "1.2.840.113556.1.4.2066"
// ControlTypeMicrosoftDirSyncEX - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftDirSyncEX = "1.2.840.113556.1.4.2090"
// ControlTypeMicrosoftUpdateStats - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftUpdateStats = "1.2.840.113556.1.4.2205"
// ControlTypeMicrosoftTreeDeleteEX - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftTreeDeleteEX = "1.2.840.113556.1.4.2204"
// ControlTypeMicrosoftSearchHints - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftSearchHints = "1.2.840.113556.1.4.2206"
// ControlTypeMicrosoftExpectedEntryCount - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftExpectedEntryCount = "1.2.840.113556.1.4.2211"
// ControlTypeMicrosoftPolicyHints - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftPolicyHints = "1.2.840.113556.1.4.2239"
// ControlTypeMicrosoftSetOwner - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftSetOwner = "1.2.840.113556.1.4.2255"
// ControlTypeMicrosoftBypassQuota - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftBypassQuota = "1.2.840.113556.1.4.2256"
// ControlTypeMicrosoftServerLinkTTL - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftServerLinkTTL = "1.2.840.113556.1.4.2309"
// ControlTypeMicrosoftSetCorrelationID - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftSetCorrelationID = "1.2.840.113556.1.4.2330"
// ControlTypeMicrosoftThreadTraceOverride - https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87db-4728-4f29-b164-01dd7d7391ea
ControlTypeMicrosoftThreadTraceOverride = "1.2.840.113556.1.4.2354"
// ControlTypeSyncRequest - https://www.ietf.org/rfc/rfc4533.txt
ControlTypeSyncRequest = "1.3.6.1.4.1.4203.1.9.1.1"
@@ -49,29 +121,85 @@ const (
)
// Flags for DirSync control
// Source: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/2213a7f2-0a36-483c-b2a4-8574d53aa1e3
const (
DirSyncIncrementalValues int64 = 2147483648
DirSyncPublicDataOnly int64 = 8192
DirSyncAncestorsFirstOrder int64 = 2048
DirSyncObjectSecurity int64 = 1
// Windows Server 2003 and later: If this flag is not present, all of the values,
// up to a server-specified limit, in a multivalued attribute are returned when
// any value changes. If this flag is present, only the changed values are
// returned, provided the attribute is a forward link value.
// Windows 2000: Not supported.
DirSyncIncrementalValues int64 = 0x80000000
// Do not return private data in the search results.
// Windows Server 2003 and later: This flag can optionally be passed to the DC,
// but it has no effect.
// Windows 2000: Not supported.
DirSyncPublicDataOnly int64 = 0x00002000
// Return parent objects before child objects, otherwise parent
// objects would appear later in the replication stream.
DirSyncAncestorsFirstOrder int64 = 0x00000800
// Windows Server 2003 operating system and later: If this flag is present,
// the client can only view objects and attributes that are otherwise accessible
// to the client. If this flag is not present, the server checks if the client
// has access rights to read the changes in the NC.
// Windows 2000 operating system: Not supported.
DirSyncObjectSecurity int64 = 0x00000001
)
// ControlTypeMap maps controls to text descriptions
var ControlTypeMap = map[string]string{
ControlTypePaging: "Paging",
ControlTypeBeheraPasswordPolicy: "Password Policy - Behera Draft",
ControlTypeManageDsaIT: "Manage DSA IT",
ControlTypeSubtreeDelete: "Subtree Delete Control",
ControlTypeMicrosoftNotification: "Change Notification - Microsoft",
ControlTypeMicrosoftShowDeleted: "Show Deleted Objects - Microsoft",
ControlTypeMicrosoftServerLinkTTL: "Return TTL-DNs for link values with associated expiry times - Microsoft",
ControlTypeServerSideSorting: "Server Side Sorting Request - LDAP Control Extension for Server Side Sorting of Search Results (RFC2891)",
ControlTypeServerSideSortingResult: "Server Side Sorting Results - LDAP Control Extension for Server Side Sorting of Search Results (RFC2891)",
ControlTypeDirSync: "DirSync",
ControlTypeSyncRequest: "Sync Request",
ControlTypeSyncState: "Sync State",
ControlTypeSyncDone: "Sync Done",
ControlTypeSyncInfo: "Sync Info",
ControlTypePaging: "Paging",
ControlTypeBeheraPasswordPolicy: "Password Policy - Behera Draft",
ControlTypeVChuPasswordMustChange: "Password Must Change - VChu Draft",
ControlTypeVChuPasswordWarning: "Password Warning - VChu Draft",
ControlTypeManageDsaIT: "Manage DSA IT",
ControlTypeWhoAmI: "Who Am I",
ControlTypeSubtreeDelete: "Subtree Delete Control",
ControlTypeServerSideSorting: "Server Side Sorting",
ControlTypeServerSideSortingResult: "Server Side Sorting Result",
ControlTypeMicrosoftCrossDomainMoveTarget: "Cross Domain Move Target - Microsoft",
ControlTypeDirSync: "DirSync",
ControlTypeMicrosoftDomainScope: "Domain Scope - Microsoft",
ControlTypeMicrosoftExtendedDN: "Extended DN - Microsoft",
ControlTypeMicrosoftGetStats: "Get Stats - Microsoft",
ControlTypeMicrosoftLazyCommit: "Lazy Commit - Microsoft",
ControlTypeMicrosoftPermissiveModify: "Permissive Modify - Microsoft",
ControlTypeMicrosoftNotification: "Change Notification - Microsoft",
ControlTypeMicrosoftSDFlags: "SD Flags - Microsoft",
ControlTypeMicrosoftSearchOptions: "Search Options - Microsoft",
ControlTypeMicrosoftShowDeleted: "Show Deleted Objects - Microsoft",
ControlTypeMicrosoftVerifyName: "Verify Name - Microsoft",
ControlTypeMicrosoftASQ: "ASQ - Microsoft",
ControlTypeMicrosoftQuotaControl: "Quota Control - Microsoft",
ControlTypeMicrosoftRangeOption: "Range Option - Microsoft",
ControlTypeMicrosoftShutdownNotify: "Shutdown Notify - Microsoft",
ControlTypeMicrosoftForceUpdate: "Force Update - Microsoft",
ControlTypeMicrosoftRangeRetrievalNoErr: "Range Retrieval No Error - Microsoft",
ControlTypeMicrosoftRODCDCPromo: "RODC DC Promo - Microsoft",
ControlTypeMicrosoftDNInput: "DN Input - Microsoft",
ControlTypeMicrosoftShowDeactivatedLink: "Show Deactivated Link - Microsoft",
ControlTypeMicrosoftShowRecycled: "Show Recycled - Microsoft",
ControlTypeMicrosoftPolicyHintsDeprecated: "Policy Hints Deprecated - Microsoft",
ControlTypeMicrosoftDirSyncEX: "DirSync EX - Microsoft",
ControlTypeMicrosoftUpdateStats: "Update Stats - Microsoft",
ControlTypeMicrosoftTreeDeleteEX: "Tree Delete EX - Microsoft",
ControlTypeMicrosoftSearchHints: "Search Hints - Microsoft",
ControlTypeMicrosoftExpectedEntryCount: "Expected Entry Count - Microsoft",
ControlTypeMicrosoftPolicyHints: "Policy Hints - Microsoft",
ControlTypeMicrosoftSetOwner: "Set Owner - Microsoft",
ControlTypeMicrosoftBypassQuota: "Bypass Quota - Microsoft",
ControlTypeMicrosoftServerLinkTTL: "Return TTL-DNs for link values with associated expiry times - Microsoft",
ControlTypeMicrosoftSetCorrelationID: "Set Correlation ID - Microsoft",
ControlTypeMicrosoftThreadTraceOverride: "Thread Trace Override - Microsoft",
ControlTypeSyncRequest: "Sync Request",
ControlTypeSyncState: "Sync State",
ControlTypeSyncDone: "Sync Done",
ControlTypeSyncInfo: "Sync Info",
}
// Control defines an interface controls provide to encode and describe themselves
@@ -316,6 +444,42 @@ func NewControlMicrosoftNotification() *ControlMicrosoftNotification {
return &ControlMicrosoftNotification{}
}
type ControlMicrosoftSDFlags struct {
Criticality bool
ControlValue int32
}
func (c *ControlMicrosoftSDFlags) GetControlType() string {
// Source: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3888c2b7-35b9-45b7-afeb-b772aa932dd0
return ControlTypeMicrosoftSDFlags
}
func (c *ControlMicrosoftSDFlags) Encode() *ber.Packet {
packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Control")
packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, ControlTypeMicrosoftSDFlags, "Control Type ("+ControlTypeMap[ControlTypeMicrosoftSDFlags]+")"))
if c.Criticality {
packet.AppendChild(ber.NewBoolean(ber.ClassUniversal, ber.TypePrimitive, ber.TagBoolean, c.Criticality, "Criticality"))
}
p2 := ber.Encode(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, nil, "Control Value(SDFlags)")
seq := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "SDFlags")
seq.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, c.ControlValue, "Flags"))
p2.AppendChild(seq)
packet.AppendChild(p2)
return packet
}
func (c *ControlMicrosoftSDFlags) String() string {
return fmt.Sprintf(
"Control Type: %s (%q)",
ControlTypeMap[ControlTypeMicrosoftSDFlags],
ControlTypeMicrosoftSDFlags)
}
// NewControlMicrosoftSDFlags returns a ControlMicrosoftSDFlags control
func NewControlMicrosoftSDFlags() *ControlMicrosoftSDFlags {
return &ControlMicrosoftSDFlags{}
}
// ControlMicrosoftShowDeleted implements the control described in https://msdn.microsoft.com/en-us/library/aa366989(v=vs.85).aspx
type ControlMicrosoftShowDeleted struct{}
@@ -509,6 +673,9 @@ func DecodeControl(packet *ber.Packet) (Control, error) {
c := &ControlVChuPasswordMustChange{MustChange: true}
return c, nil
case ControlTypeVChuPasswordWarning:
if value == nil || value.Data == nil {
return nil, fmt.Errorf("invalid value for Control Type ControlTypeVChuPasswordWarning: %v", value)
}
c := &ControlVChuPasswordWarning{Expire: -1}
expireStr := ber.DecodeString(value.Data.Bytes())

View File

@@ -1,7 +1,9 @@
package ldap
import (
"errors"
"fmt"
ber "github.com/go-asn1-ber/asn1-ber"
)
@@ -35,6 +37,10 @@ func NewDelRequest(DN string, Controls []Control) *DelRequest {
// Del executes the given delete request
func (l *Conn) Del(delRequest *DelRequest) error {
if delRequest == nil {
return NewError(ErrorNetwork, errors.New("DelRequest cannot be nil"))
}
msgCtx, err := l.doRequest(delRequest)
if err != nil {
return err

View File

@@ -1,7 +1,9 @@
package ldap
import (
"errors"
"fmt"
ber "github.com/go-asn1-ber/asn1-ber"
)
@@ -56,6 +58,10 @@ type ExtendedResponse struct {
// Extended performs an extended request. The resulting
// ExtendedResponse may return a value in the form of a *ber.Packet
func (l *Conn) Extended(er *ExtendedRequest) (*ExtendedResponse, error) {
if er == nil {
return nil, NewError(ErrorNetwork, errors.New("ExtendedRequest cannot be nil"))
}
msgCtx, err := l.doRequest(er)
if err != nil {
return nil, err

View File

@@ -246,38 +246,19 @@ func readTag(f reflect.StructField) (string, bool) {
// // ...
// }
func (e *Entry) Unmarshal(i interface{}) (err error) {
// Make sure it's a ptr
if vo := reflect.ValueOf(i).Kind(); vo != reflect.Ptr {
return fmt.Errorf("ldap: cannot use %s, expected pointer to a struct", vo)
}
sv, st := reflect.ValueOf(i).Elem(), reflect.TypeOf(i).Elem()
// Make sure it's pointing to a struct
if sv.Kind() != reflect.Struct {
return fmt.Errorf("ldap: expected pointer to a struct, got %s", sv.Kind())
}
for n := 0; n < st.NumField(); n++ {
// Holds struct field value and type
fv, ft := sv.Field(n), st.Field(n)
// skip unexported fields
if ft.PkgPath != "" {
continue
}
return e.UnmarshalFunc(i, func(entry *Entry, ft reflect.StructField, fv reflect.Value) error {
// omitempty can be safely discarded, as it's not needed when unmarshalling
fieldTag, _ := readTag(ft)
// Fill the field with the distinguishedName if the tag key is `dn`
if fieldTag == "dn" {
fv.SetString(e.DN)
continue
return nil
}
values := e.GetAttributeValues(fieldTag)
if len(values) == 0 {
continue
return nil
}
switch fv.Interface().(type) {
@@ -320,8 +301,39 @@ func (e *Entry) Unmarshal(i interface{}) (err error) {
default:
return fmt.Errorf("ldap: expected field to be of type string, *string, []string, int, int64, []byte, *DN, []*DN or time.Time, got %v", ft.Type)
}
return nil
})
}
// UnmarshalFunc allows you to define a custom unmarshaler to parse an Entry values.
// A custom unmarshaler can be found in the Unmarshal function or in the test files.
func (e *Entry) UnmarshalFunc(i interface{},
fn func(entry *Entry, fieldType reflect.StructField, fieldValue reflect.Value) error) error {
// Make sure it's a ptr
if vo := reflect.ValueOf(i).Kind(); vo != reflect.Ptr {
return fmt.Errorf("ldap: cannot use %s, expected pointer to a struct", vo)
}
return
sv, st := reflect.ValueOf(i).Elem(), reflect.TypeOf(i).Elem()
// Make sure it's pointing to a struct
if sv.Kind() != reflect.Struct {
return fmt.Errorf("ldap: expected pointer to a struct, got %s", sv.Kind())
}
for n := 0; n < st.NumField(); n++ {
fv, ft := sv.Field(n), st.Field(n)
// skip unexported fields
if ft.PkgPath != "" {
continue
}
if err := fn(e, ft, fv); err != nil {
return err
}
}
return nil
}
// NewEntryAttribute returns a new EntryAttribute with the desired key-value pair

2
vendor/modules.txt vendored
View File

@@ -552,7 +552,7 @@ github.com/go-jose/go-jose/v4/json
## explicit; go 1.17
github.com/go-kit/log
github.com/go-kit/log/level
# github.com/go-ldap/ldap/v3 v3.4.11
# github.com/go-ldap/ldap/v3 v3.4.12
## explicit; go 1.23.0
github.com/go-ldap/ldap/v3
# github.com/go-ldap/ldif v0.0.0-20200320164324-fd88d9b715b3