Documentation
¶
Overview ¶
Package adldap manages Active Directory over LDAP, directly from Go, with no PowerShell and no Windows host anywhere in the chain.
It satisfies the same adcore.Directory contract as go-adpwsh, so a consumer written against one works against the other unchanged. TLS is mandatory: LDAPS on 636 or StartTLS on 389. Plain LDAP is not offered, because a simple bind over it sends the password in clear text and a domain with LDAP signing required refuses it anyway.
Index ¶
Constants ¶
const ( ControlPaging = "1.2.840.113556.1.4.319" ControlShowDeleted = "1.2.840.113556.1.4.417" ControlSDFlags = "1.2.840.113556.1.4.801" ControlExtendedDN = "1.2.840.113556.1.4.529" )
Microsoft LDAP control OIDs.
const MatchingRuleInChain = "1.2.840.113556.1.4.1941"
MatchingRuleInChain is LDAP_MATCHING_RULE_IN_CHAIN, which walks nested group membership server-side.
Variables ¶
This section is empty.
Functions ¶
func DefaultPort ¶
DefaultPort is the port a mode uses when Config.Port is zero.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the entry point. Hand it to a consumer through Directory.
func New ¶
New validates the configuration, opens and binds one connection, reads the rootDSE, and pins the domain controller this client targets for its lifetime. It performs one round trip.
The DC is pinned rather than rediscovered because a create that lands on DC-A and a read-back that hits DC-B reports "not found". Config.Server names it; there is deliberately no discovery.
func NewWithConn ¶
func NewWithConn(ctx context.Context, cfg Config, dial func(context.Context) (conn.Conn, error)) (*Client, error)
NewWithConn builds a Client over a caller-supplied connection factory rather than dialling one.
It exists because the in-process LDAP server this module tests against cannot serve ModifyDN — the library behind it parses no such request — and ModifyDN is how a rename and a move happen. Without a seam here, the rename-and-move contract could be tested only against a real domain. The factory's type names an internal package, so nothing outside this module can supply one.
func (*Client) DefaultNamingContext ¶
DefaultNamingContext returns the domain's naming context.
func (*Client) Directory ¶
Directory presents this client through the backend-neutral contract.
The classes this backend does not implement are filled with stubs that return KindUnsupported, naming the class. They were nil interface fields until the lab showed what that actually costs: a consumer dereferences the nil and panics, which aborted an entire acceptance run and named neither the class nor the reason.
type Config ¶
type Config struct {
// Server is the domain controller this client pins for its lifetime.
Server string
Port int
TLS TLSMode
// CACertificateFile verifies the DC's certificate. Empty uses the system
// pool.
CACertificateFile string
// InsecureSkipVerify disables certificate verification. It is never a
// default and exists only for labs with self-signed DC certificates.
InsecureSkipVerify bool
// TLSConfig, when set, wins over the three fields above. Test hook.
TLSConfig *tls.Config
// Exactly one of these.
Simple *SimpleAuth
Kerberos *KerberosAuth
NTLM *NTLMAuth
// MaxConcurrency bounds pooled connections. Zero means 4.
MaxConcurrency int
// Timeout is the per-operation deadline. Zero means 60s.
Timeout time.Duration
Retry adcore.RetryConfig
Replication ReplicationConfig
Log Logger
}
Config configures a Client. Server, TLS and exactly one auth block are required.
type KerberosAuth ¶
type KerberosAuth struct {
// CCachePath names a credential cache file explicitly.
CCachePath string
// Keytab and Username authenticate unattended, for CI with no kinit.
Keytab string
Username string
// Password authenticates from a supplied credential, for a runner where
// kinit was never installed at all. It requires Username. With no
// Krb5ConfPath and no /etc/krb5.conf, a minimal configuration is
// synthesized from Realm and Server — otherwise this path would work only
// where it was least needed.
Password adcore.Secret
// Realm defaults to Server's domain suffix, uppercased.
Realm string
// Krb5ConfPath overrides /etc/krb5.conf.
Krb5ConfPath string
// SPN overrides the service principal, which defaults to ldap/<server>.
SPN string
}
KerberosAuth binds with a Kerberos ticket. The zero value uses the ambient credential cache, which is the preferred path: an operator runs kinit in their own shell and no password reaches Terraform configuration.
At most one of CCachePath, Keytab and Password may be set. With none set the ambient KRB5CCNAME applies.
type Logger ¶
Logger is the output port. The package masks credential-bearing values before anything reaches it: redaction cannot be the caller's job, because the caller never sees the payload.
type ReplicationConfig ¶
type ReplicationConfig struct {
Wait bool
Targets []string // DC host names, or the single element "all"
ForceSync bool
Timeout time.Duration
PollInterval time.Duration
}
ReplicationConfig governs the wait that follows a write.
type SimpleAuth ¶
SimpleAuth is a username and password bind. It requires TLS, which this package always has.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
adtest
Package adtest runs an in-process LDAP server backed by an in-memory directory, so this module's wire behaviour — attribute encoding, controls, filters, paging, binds — is exercised in CI rather than first on a lab domain.
|
Package adtest runs an in-process LDAP server backed by an in-memory directory, so this module's wire behaviour — attribute encoding, controls, filters, paging, binds — is exercised in CI rather than first on a lab domain. |
|
attrs
Package attrs encodes and decodes the Active Directory attribute values the cmdlets used to hide.
|
Package attrs encodes and decodes the Active Directory attribute values the cmdlets used to hide. |
|
conn
Package conn is the only place this module knows what LDAP library it uses.
|
Package conn is the only place this module knows what LDAP library it uses. |
|
ldaperr
Package ldaperr turns an LDAP failure into the same adcore.Kind the PowerShell backend would produce for the same condition.
|
Package ldaperr turns an LDAP failure into the same adcore.Kind the PowerShell backend would produce for the same condition. |
|
secdesc
Package secdesc edits the one part of an Active Directory security descriptor this backend needs: the Deny ACE that implements ProtectedFromAccidentalDeletion.
|
Package secdesc edits the one part of an Active Directory security descriptor this backend needs: the Deny ACE that implements ProtectedFromAccidentalDeletion. |