Documentation
¶
Overview ¶
Package adws - Type conversion between ADWS and LDAP formats
Package adws - High-level ADWS client for Active Directory query and transfer operations
Index ¶
- func ConvertGUIDBytes(guidBytes []byte) (string, error)
- func ConvertSIDBytes(sidBytes []byte) (string, error)
- func DetectAttributeType(attrName string) string
- type ADCAPActiveDirectoryDomain
- type ADCAPActiveDirectoryDomainController
- type ADCAPActiveDirectoryForest
- type ADCAPActiveDirectoryGroup
- type ADCAPActiveDirectoryObject
- type ADCAPActiveDirectoryPrincipal
- type ADCAPVersionInfo
- type ADWSItem
- type ADWSValue
- type Config
- type IMDAAttribute
- type NameTranslateResult
- type WSClient
- func (c *WSClient) ADCAPChangeOptionalFeature(distinguishedName string, enable bool, featureID string) error
- func (c *WSClient) ADCAPChangePassword(accountDN, partitionDN, oldPassword, newPassword string) error
- func (c *WSClient) ADCAPGetADDomain() (*ADCAPActiveDirectoryDomain, error)
- func (c *WSClient) ADCAPGetADDomainControllers(ntdsSettingsDNs []string) ([]ADCAPActiveDirectoryDomainController, error)
- func (c *WSClient) ADCAPGetADForest() (*ADCAPActiveDirectoryForest, error)
- func (c *WSClient) ADCAPGetADGroupMember(groupDN, partitionDN string, recursive bool) ([]ADCAPActiveDirectoryPrincipal, error)
- func (c *WSClient) ADCAPGetADPrincipalAuthorizationGroup(principalDN, partitionDN string) ([]ADCAPActiveDirectoryGroup, error)
- func (c *WSClient) ADCAPGetADPrincipalGroupMembership(...) ([]ADCAPActiveDirectoryGroup, error)
- func (c *WSClient) ADCAPGetVersion() (*ADCAPVersionInfo, error)
- func (c *WSClient) ADCAPSetPassword(accountDN, partitionDN, newPassword string) error
- func (c *WSClient) ADCAPTranslateName(formatOffered, formatDesired string, names []string) ([]NameTranslateResult, error)
- func (c *WSClient) Close() error
- func (c *WSClient) Connect() error
- func (c *WSClient) Get(dn string, attrs []string) (*ADWSItem, error)
- func (c *WSClient) GetDCFQDN() string
- func (c *WSClient) GetMetadata() (*wsmex.ADWSMetadata, error)
- func (c *WSClient) IsConnected() bool
- func (c *WSClient) PrincipalAuthorizationGroups(principalDN string) ([]ADWSItem, error)
- func (c *WSClient) PrincipalGroupMembership(principalDN string) ([]ADWSItem, error)
- func (c *WSClient) Query(baseDN, filter string, attrs []string, scope int) ([]ADWSItem, error)
- func (c *WSClient) QueryWithBatchChannel(baseDN, filter string, attrs []string, scope, maxElementsPerPull int, ...) error
- func (c *WSClient) QueryWithCallback(baseDN, filter string, attrs []string, scope int, ...) error
- func (c *WSClient) SetDebugXML(enabled bool)
- func (c *WSClient) SetTimeout(timeout time.Duration)
- func (c *WSClient) WSTransferAddComputer(parentDN, computerName, computerPass string) (string, error)
- func (c *WSClient) WSTransferAddContainer(parentDN, cn string) (string, error)
- func (c *WSClient) WSTransferAddGroup(parentDN, groupName, groupType string) (string, error)
- func (c *WSClient) WSTransferAddOU(parentDN, ouName string) (string, error)
- func (c *WSClient) WSTransferAddUser(parentDN, userName, userPass string, enabled bool) (string, error)
- func (c *WSClient) WSTransferCreate(instanceXML string) (string, error)
- func (c *WSClient) WSTransferCreateComputer(parentDN, computerName string) (string, error)
- func (c *WSClient) WSTransferCreateCustom(parentDN, rdn string, attrs []IMDAAttribute) (string, error)
- func (c *WSClient) WSTransferDelete(dn string) error
- func (c *WSClient) WSTransferGet(dn string, attrs []string) (*ADWSItem, error)
- func (c *WSClient) WSTransferModifyAttribute(dn, operation, attr string, values []string) error
- func (c *WSClient) WSTransferPut(dn, instanceXML string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertGUIDBytes ¶
ConvertGUIDBytes converts a binary GUID to standard GUID format.
GUID format (mixed-endian):
[0:4] Data1 (little-endian) [4:6] Data2 (little-endian) [6:8] Data3 (little-endian) [8:16] Data4 (big-endian, 8 bytes)
Output format: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
func ConvertSIDBytes ¶
ConvertSIDBytes converts a binary SID to S-1-5-... format.
SID format:
[0] Revision (always 1) [1] SubAuthorityCount (number of SubAuthorities) [2:8] IdentifierAuthority (6 bytes, big-endian) [8:] SubAuthorities (4 bytes each, little-endian)
func DetectAttributeType ¶
DetectAttributeType attempts to detect the binary attribute type by name.
This is needed because OctetString is ambiguous - it can be SID, GUID, or other binary data.
Types ¶
type ADCAPActiveDirectoryDomain ¶
type ADCAPActiveDirectoryDomain = soap.ADCAPActiveDirectoryDomain
ADCAPActiveDirectoryDomain is the public alias for an MS-ADCAP ActiveDirectoryDomain.
type ADCAPActiveDirectoryDomainController ¶
type ADCAPActiveDirectoryDomainController = soap.ADCAPActiveDirectoryDomainController
ADCAPActiveDirectoryDomainController is the public alias for an MS-ADCAP ActiveDirectoryDomainController.
type ADCAPActiveDirectoryForest ¶
type ADCAPActiveDirectoryForest = soap.ADCAPActiveDirectoryForest
ADCAPActiveDirectoryForest is the public alias for an MS-ADCAP ActiveDirectoryForest.
type ADCAPActiveDirectoryGroup ¶
type ADCAPActiveDirectoryGroup = soap.ADCAPActiveDirectoryGroup
ADCAPActiveDirectoryGroup is the public alias for an MS-ADCAP ActiveDirectoryGroup.
type ADCAPActiveDirectoryObject ¶
type ADCAPActiveDirectoryObject = soap.ADCAPActiveDirectoryObject
ADCAPActiveDirectoryObject is the public alias for an MS-ADCAP ActiveDirectoryObject.
type ADCAPActiveDirectoryPrincipal ¶
type ADCAPActiveDirectoryPrincipal = soap.ADCAPActiveDirectoryPrincipal
ADCAPActiveDirectoryPrincipal is the public alias for an MS-ADCAP ActiveDirectoryPrincipal.
type ADCAPVersionInfo ¶
type ADCAPVersionInfo = soap.ADCAPVersionInfo
ADCAPVersionInfo is the public alias for an MS-ADCAP GetVersion result.
type Config ¶
type Config struct {
DCFQDN string // DC fully-qualified domain name (required)
Port int // ADWS port (default 9389)
LDAPPort int // LDAP port used in SOAP headers for the target directory service (default 389; use 3268 for GC)
Username string // Domain\username or username@domain (required)
Password string // Password (optional if NTHash/CCachePath/PFX/Cert provided)
NTHash string // NT hash auth (optional)
AESKey string // Kerberos AES-128 or AES-256 session key, hex-encoded (optional, implies Kerberos)
CCachePath string // Kerberos ccache path (optional, implies Kerberos)
PFXFile string // PKCS#12 (.pfx/.p12) certificate file for PKINIT (optional)
PFXPassword string // Password for PFX file (optional, default empty)
CertFile string // PEM certificate file for PKINIT (use with KeyFile)
KeyFile string // PEM RSA private key file for PKINIT (use with CertFile)
UseKerberos bool // Use SPNEGO/Kerberos negotiation
Domain string // Domain name (required)
Timeout time.Duration // Connection timeout (default 30s)
UseTLS bool // Use TLS (future - currently not supported by ADWS)
DebugXML bool // Print raw SOAP XML when true (or via ADWS_DEBUG_XML=1)
}
Config contains ADWS client configuration.
type IMDAAttribute ¶
IMDAAttribute describes an attribute for an IMDA AddRequest.
Name should be a fully qualified attribute type (e.g. "addata:cn", "addata:objectClass"). XSIType should be an xsd:* type (e.g. "xsd:string", "xsd:int", "xsd:base64Binary"). Values contains 1+ values for the attribute.
type NameTranslateResult ¶
type NameTranslateResult = soap.NameTranslateResult
NameTranslateResult is the public alias for an MS-ADCAP TranslateName result.
type WSClient ¶
type WSClient struct {
// contains filtered or unexported fields
}
WSClient represents an ADWS client for querying and transfer operations in Active Directory.
ADWS provides an alternative to traditional LDAP (ports 389/3268) by using port 9389 with SOAP/XML over an authenticated and encrypted channel.
Protocol stack (bottom to top):
- TCP connection to dc.domain.com:9389
- NNS (.NET NegotiateStream) - NTLM/Kerberos authentication with signing/sealing
- NMF (.NET Message Framing) - Record boundaries and encoding negotiation
- SOAP/XML - WS-Enumeration/WS-Transfer protocol operations
func NewWSClient ¶
NewWSClient creates a new ADWS client with the given configuration. Credential fields (Username, Password, etc.) are validated at Connect() time, so callers that only intend to call GetMetadata() may omit them.
func (*WSClient) ADCAPChangeOptionalFeature ¶
func (c *WSClient) ADCAPChangeOptionalFeature(distinguishedName string, enable bool, featureID string) error
ADCAPChangeOptionalFeature enables or disables an optional feature in a naming context.
func (*WSClient) ADCAPChangePassword ¶
func (c *WSClient) ADCAPChangePassword(accountDN, partitionDN, oldPassword, newPassword string) error
ADCAPChangePassword changes the password for the specified account DN in the specified partition.
func (*WSClient) ADCAPGetADDomain ¶
func (c *WSClient) ADCAPGetADDomain() (*ADCAPActiveDirectoryDomain, error)
ADCAPGetADDomain returns information about the domain containing the directory service.
func (*WSClient) ADCAPGetADDomainControllers ¶
func (c *WSClient) ADCAPGetADDomainControllers(ntdsSettingsDNs []string) ([]ADCAPActiveDirectoryDomainController, error)
ADCAPGetADDomainControllers returns info about domain controllers for the given nTDSDSA settings DNs.
func (*WSClient) ADCAPGetADForest ¶
func (c *WSClient) ADCAPGetADForest() (*ADCAPActiveDirectoryForest, error)
ADCAPGetADForest returns information about the forest containing the directory service.
func (*WSClient) ADCAPGetADGroupMember ¶
func (c *WSClient) ADCAPGetADGroupMember(groupDN, partitionDN string, recursive bool) ([]ADCAPActiveDirectoryPrincipal, error)
ADCAPGetADGroupMember returns the members of the specified group.
func (*WSClient) ADCAPGetADPrincipalAuthorizationGroup ¶
func (c *WSClient) ADCAPGetADPrincipalAuthorizationGroup(principalDN, partitionDN string) ([]ADCAPActiveDirectoryGroup, error)
ADCAPGetADPrincipalAuthorizationGroup returns the security-enabled groups used for authorization for a principal.
func (*WSClient) ADCAPGetADPrincipalGroupMembership ¶
func (c *WSClient) ADCAPGetADPrincipalGroupMembership(principalDN, partitionDN, resourceContextPartition, resourceContextServer string) ([]ADCAPActiveDirectoryGroup, error)
ADCAPGetADPrincipalGroupMembership returns a set of groups associated with the specified principal.
Note: per MS-ADCAP, this returns direct group membership only (no transitive expansion).
func (*WSClient) ADCAPGetVersion ¶
func (c *WSClient) ADCAPGetVersion() (*ADCAPVersionInfo, error)
ADCAPGetVersion returns ADWS Custom Action Protocol version information.
func (*WSClient) ADCAPSetPassword ¶
ADCAPSetPassword sets the password for the specified account DN in the specified partition.
func (*WSClient) ADCAPTranslateName ¶
func (c *WSClient) ADCAPTranslateName(formatOffered, formatDesired string, names []string) ([]NameTranslateResult, error)
ADCAPTranslateName translates an array of names from one format to another. Valid formats: DistinguishedName, CanonicalName.
func (*WSClient) GetMetadata ¶
func (c *WSClient) GetMetadata() (*wsmex.ADWSMetadata, error)
GetMetadata fetches and parses the WS-MetadataExchange document from the unauthenticated ADWS MEX endpoint. No credentials are required.
func (*WSClient) IsConnected ¶
IsConnected returns true if the client is connected.
func (*WSClient) PrincipalAuthorizationGroups ¶
PrincipalAuthorizationGroups returns the security-enabled groups used for authorization decisions for the specified principal, using the MS-ADCAP GetADPrincipalAuthorizationGroup custom action.
func (*WSClient) PrincipalGroupMembership ¶
PrincipalGroupMembership returns a set of groups associated with the specified principal, using the MS-ADCAP GetADPrincipalGroupMembership custom action.
Note: per MS-ADCAP, no transitive group membership evaluation is performed.
func (*WSClient) QueryWithBatchChannel ¶
func (c *WSClient) QueryWithBatchChannel(baseDN, filter string, attrs []string, scope, maxElementsPerPull int, batchChannel chan<- []ADWSItem) error
QueryWithBatchChannel performs an LDAP query and streams each Pull batch to batchChannel.
func (*WSClient) QueryWithCallback ¶
func (c *WSClient) QueryWithCallback(baseDN, filter string, attrs []string, scope int, callback func(items []ADWSItem) error) error
QueryWithCallback performs an LDAP query and calls a callback for each batch of results.
func (*WSClient) SetDebugXML ¶
SetDebugXML enables/disables raw SOAP response logging.
func (*WSClient) SetTimeout ¶
SetTimeout sets the connection timeout.
func (*WSClient) WSTransferAddComputer ¶
func (c *WSClient) WSTransferAddComputer(parentDN, computerName, computerPass string) (string, error)
WSTransferAddComputer executes a WS-Transfer Create (IMDA AddRequest) against the ResourceFactory endpoint to create a computer account under parentDN.
This mirrors SharpADWS' AddComputer method and sets unicodePwd, dNSHostName, userAccountControl, and servicePrincipalName.
func (*WSClient) WSTransferAddContainer ¶
WSTransferAddContainer creates a container object under parentDN via ResourceFactory.
func (*WSClient) WSTransferAddGroup ¶
WSTransferAddGroup creates a group object under parentDN via ResourceFactory.
func (*WSClient) WSTransferAddOU ¶
WSTransferAddOU creates an organizationalUnit object under parentDN via ResourceFactory.
func (*WSClient) WSTransferAddUser ¶
func (c *WSClient) WSTransferAddUser(parentDN, userName, userPass string, enabled bool) (string, error)
WSTransferAddUser creates a user object under parentDN via ResourceFactory.
func (*WSClient) WSTransferCreate ¶
WSTransferCreate executes a WS-Transfer Create against the ResourceFactory endpoint.
The returned address is best-effort and may be empty if the server response does not include a parsable ResourceCreated/Address or objectReferenceProperty.
func (*WSClient) WSTransferCreateComputer ¶
WSTransferCreateComputer executes a WS-Transfer Create (IMDA AddRequest) against the ResourceFactory endpoint to create a simple computer object under parentDN.
This is a state-changing operation.
func (*WSClient) WSTransferCreateCustom ¶
func (c *WSClient) WSTransferCreateCustom(parentDN, rdn string, attrs []IMDAAttribute) (string, error)
WSTransferCreateCustom creates a custom object via WS-Transfer ResourceFactory using an IMDA AddRequest.
parentDN is the container DN; rdn is the relative distinguished name (e.g. "CN=MyObject"). The required IMDA attributes ad:relativeDistinguishedName and ad:container-hierarchy-parent are always injected.
func (*WSClient) WSTransferDelete ¶
WSTransferDelete executes a WS-Transfer Delete against the Resource endpoint.
func (*WSClient) WSTransferGet ¶
WSTransferGet executes a WS-Transfer Get against the Resource endpoint.
func (*WSClient) WSTransferModifyAttribute ¶
WSTransferModifyAttribute performs a WS-Transfer Put using an IMDA ModifyRequest.
operation must be one of: add, replace, delete. attr may be either a local attribute name (e.g. "description") or a fully-qualified type (e.g. "addata:description"). Values are treated as xsd:string.
func (*WSClient) WSTransferPut ¶
WSTransferPut executes a WS-Transfer Put against the Resource endpoint.