adsi

package module
v0.0.0-...-153c760 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2018 License: MIT Imports: 15 Imported by: 3

README

Go language bindings for ADSI

This package provides access to the Active Directory Service Interfaces that are available through the Windows component object model API. This package should compile on any platform but implementations are only provided for Windows.

The adsi package provides high level and idiomatic access to ADSI. It in turn relies on the api package, which handles the low level details of COM binding and is analogous to Go's syscall package.

This project is a work in progress. Only a small subset of the available interfaces have been implemented.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrClosed is returned from calls to a service or interface in the event
	// that the Close() function has already been called.
	ErrClosed = errors.New("interface is closing or already closed")

	// ErrNonDispatchVariant is returned when an attempt is made to cast an
	// ole.VARIANT to an ole.IDispatch type, but the VARIANT is of some other
	// This might happen, for example, when an iterator is interrogating the
	// members of an IEnumVARIANT in an attempt to convert them into an expected
	// type.
	ErrNonDispatchVariant = errors.New("object iterator unexpectedly yielded non-dispatch variant")

	// ErrInvalidGUID is returned when a given value cannot be interpreted as
	// a globally unique identifier.
	ErrInvalidGUID = errors.New("invalid GUID")

	// ErrNonArrayAttribute is returned when a given attribute cannot be converted
	// to a safe array.
	ErrNonArrayAttribute = errors.New("attribute is not an array")

	// ErrMultiDimArrayAttribute is returned when an attribute contains more than
	// one dimension in its array of values.
	ErrMultiDimArrayAttribute = errors.New("attribute contains a multi-dimensional array of values")

	// ErrNonVariantArrayAttribute is returned when the array members of a given
	// attribute are not variants.
	ErrNonVariantArrayAttribute = errors.New("attribute contains non-variant array members")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides access to Active Directory Service Interfaces for any namespace supported by a local or remote COM server.

func NewClient

func NewClient() (*Client, error)

NewClient creates a new ADSI client. When done with a client it should be closed with a call to Close(). If NewClient is successful it will return a client and error will be nil, otherwise the returned client will be nil and error will be non-nil.

func NewRemoteClient

func NewRemoteClient(server string) (*Client, error)

NewRemoteClient creates a new ADSI client on a remote server. When done with a client it should be closed with a call to Close(). If NewClient is successful it will return a client and error will be nil, otherwise the returned client will be nil and error will be non-nil.

If no server is provided a local client is created instead and the resulting behavior is identical to NewClient.

func (*Client) Close

func (c *Client) Close()

Close will release resources consumed by the client. It should be called when the client is no longer needed.

func (*Client) Flags

func (c *Client) Flags() (flags uint32)

Flags returns the default flags that are used when opening a connection.

func (*Client) Open

func (c *Client) Open(path string) (obj *Object, err error)

Open opens an ADSI object with the given path. The existing security context of the application and any flags specified via SetFlags will be used when making the connection. The default flags specify an encrypted read-only connection.

Open returns the ADSI object as an Object type, which provides an idiomatic go wrapper around the underlying component object model IADs interface.

Open calls QueryInterface internally to acquire an implementation of the IADs interface that is needed by the Object type. If the returned directory object does not implement the IADs interface an error is returned.

The returned object consumes resources until it is closed. It is the caller's responsibilty to call Close on the returned object when it is no longer needed.

func (*Client) OpenComputer

func (c *Client) OpenComputer(path string) (computer *Computer, err error)

OpenComputer opens an ADSI computer with the given path. The existing security context of the application and any flags specified via SetFlags will be used when making the connection. The default flags specify an encrypted read-only connection.

OpenComputer returns the ADSI computer as a Computer type, which provides an idiomatic go wrapper around the underlying component object model IADsComputer interface.

OpenComputer calls QueryInterface internally to acquire an implementation of the IADsComputer interface that is needed by the Object type. If the returned directory object does not implement the IADsComputer interface an error is returned.

The returned computer consumes resources until it is closed. It is the caller's responsibilty to call Close on the returned computer when it is no longer needed.

func (*Client) OpenComputerSC

func (c *Client) OpenComputerSC(path, user, password string, flags uint32) (computer *Computer, err error)

OpenComputerSC opens an ADSI computer with the given path. When provided, the username and password are used to establish a security context for the connection. When credentials are not provided the existing security context of the application is used instead. The provided flags will be used when making the connection.

OpenComputerSC returns the ADSI computer as a Computer type, which provides an idiomatic go wrapper around the underlying component object model IADsComputer interface.

OpenComputerSC calls QueryInterface internally to acquire an implementation of the IADsComputer interface that is needed by the Object type. If the returned directory object does not implement the IADsComputer interface an error is returned.

The returned computer consumes resources until it is closed. It is the caller's responsibilty to call Close on the returned computer when it is no longer needed.

func (*Client) OpenContainer

func (c *Client) OpenContainer(path string) (container *Container, err error)

OpenContainer opens an ADSI container with the given path. The existing security context of the application and any flags specified via SetFlags will be used when making the connection. The default flags specify an encrypted read-only connection.

OpenContainer returns the ADSI container as a Container type, which provides an idiomatic go wrapper around the underlying component object model IADsContainer interface.

OpenContainer calls QueryInterface internally to acquire an implementation of the IADsContainer interface that is needed by the Object type. If the returned directory object does not implement the IADsContainer interface an error is returned.

The returned container consumes resources until it is closed. It is the caller's responsibilty to call Close on the returned container when it is no longer needed.

func (*Client) OpenContainerSC

func (c *Client) OpenContainerSC(path, user, password string, flags uint32) (container *Container, err error)

OpenContainerSC opens an ADSI container with the given path. When provided, the username and password are used to establish a security context for the connection. When credentials are not provided the existing security context of the application is used instead. The provided flags will be used when making the connection.

OpenContainerSC returns the ADSI container as a Container type, which provides an idiomatic go wrapper around the underlying component object model IADsContainer interface.

OpenContainerSC calls QueryInterface internally to acquire an implementation of the IADsContainer interface that is needed by the Object type. If the returned directory object does not implement the IADsContainer interface an error is returned.

The returned container consumes resources until it is closed. It is the caller's responsibilty to call Close on the returned container when it is no longer needed.

func (*Client) OpenDispatch

func (c *Client) OpenDispatch(path string) (obj *ole.IDispatch, err error)

OpenDispatch opens an ADSI object with the given path. The existing security context of the application and any flags specified via SetFlags will be used when making the connection. The default flags specify an encrypted read-only connection.

OpenDispatch returns a generic IDispatch interface for the object, which can be further interrogated to find out which component object model interfaces it implements.

To return an object that has already been wrapped in the more convenient and safer Object type, use Open instead.

To open an object with a specific interface ID, use OpenInterface instead.

The returned interface consumes resources until it is released. It is the caller's responsibilty to call Release on the returned object when it is no longer needed.

func (*Client) OpenDispatchSC

func (c *Client) OpenDispatchSC(path, user, password string, flags uint32) (obj *ole.IDispatch, err error)

OpenDispatchSC opens an ADSI object with the given path. When provided, the username and password are used to establish a security context for the connection. When credentials are not provided the existing security context of the application is used instead. The provided flags will be used when making the connection.

OpenDispatchSC returns a generic IDispatch interface for the object, which can be further interrogated to find out which component object model interfaces it implements.

To return an object that has already been wrapped in the more convenient and safer Object type, use OpenSC instead.

To open an object with a specific interface ID, use OpenInterface instead.

The returned interface consumes resources until it is released. It is the caller's responsibilty to call Release on the returned object when it is no longer needed.

func (*Client) OpenInterface

func (c *Client) OpenInterface(path string, iid uuid.UUID) (obj *ole.IDispatch, err error)

OpenInterface opens a directory object with the given path. The existing security context of the application and any flags specified via SetFlags will be used when making the connection. The default flags specify an encrypted read-only connection.

OpenInterface calls QueryInterface internally to return a pointer to an object implementing the requested interface ID. If the returned object does not implement the requested interface an error is returned. The object is returned as a pointer to an IDispatch interface; it is expected that the caller will recast it as a pointer to the requested implementation.

To return an object that has already been wrapped in the more convenient and safer Object type, use OpenObject instead.

The returned interface consumes resources until it is released. It is the caller's responsibilty to call Release on the returned object when it is no longer needed.

func (*Client) OpenInterfaceSC

func (c *Client) OpenInterfaceSC(path, user, password string, flags uint32, iid uuid.UUID) (obj *ole.IDispatch, err error)

OpenInterfaceSC opens a directory object with the given path. When provided, the username and password are used to establish a security context for the connection. When credentials are not provided the existing security context of the application is used instead. The provided flags will be used when making the connection.

OpenInterfaceSC calls QueryInterface internally to return a pointer to an object implementing the requested interface ID. If the returned object does not implement the requested interface an error is returned. The object is returned as a pointer to an IDispatch interface; it is expected that the caller will recast it as a pointer to the requested implementation.

To return an object that has already been wrapped in the more convenient and safer Object type, use OpenObject instead.

The returned interface consumes resources until it is released. It is the caller's responsibilty to call Release on the returned object when it is no longer needed.

func (*Client) OpenSC

func (c *Client) OpenSC(path, user, password string, flags uint32) (obj *Object, err error)

OpenSC opens an ADSI object with the given path. When provided, the username and password are used to establish a security context for the connection. When credentials are not provided the existing security context of the application is used instead. The provided flags will be used when making the connection.

OpenSC returns the ADSI object as an Object type, which provides an idiomatic go wrapper around the underlying component object model IADs interface.

OpenSC calls QueryInterface internally to acquire an implementation of the IADs interface that is needed by the Object type. If the returned directory object does not implement the IADs interface an error is returned.

The returned object consumes resources until it is closed. It is the caller's responsibilty to call Close on the returned object when it is no longer needed.

func (*Client) SetFlags

func (c *Client) SetFlags(flags uint32)

SetFlags sets the default flags that are used when opening a connection.

type Computer

type Computer struct {
	// contains filtered or unexported fields
}

Computer provides access to Active Directory computers.

func NewComputer

func NewComputer(iface *api.IADsComputer) *Computer

NewComputer returns a computer that manages the given COM interface.

func OpenComputer

func OpenComputer(path string) (computer *Computer, err error)

OpenComputer opens an ADSI computer with the given path. The existing security context of the application and any flags specified via SetFlags will be used when making the connection. The default flags specify an encrypted read-only connection.

OpenComputer returns the ADSI computer as a Computer type, which provides an idiomatic go wrapper around the underlying component object model IADsComputer interface.

If the returned directory object does not implement the IADsComputer interface an error is returned.

The returned computer consumes resources until it is closed. It is the caller's responsibilty to call Close on the returned computer when it is no longer needed.

func OpenComputerSC

func OpenComputerSC(path, user, password string, flags uint32) (computer *Computer, err error)

OpenComputerSC opens an ADSI computer with the given path. Most users will use OpenComputer instead. It creates an ephemeral local client and uses it to open the requested computer.

When provided, the username and password are used to establish a security context for the connection. When they are not provided the existing security context of the application is used instead. The provided flags will be used to make the connection.

OpenComputerSC returns the ADSI computer as a Computer type, which provides an idiomatic go wrapper around the underlying component object model IADsComputer interface.

If the returned directory object does not implement the IADsComputer interface an error is returned.

The returned computer consumes resources until it is closed. It is the caller's responsibilty to call Close on the returned computer when it is no longer needed.

func (*Computer) Attr

func (o *Computer) Attr(name string) (values []interface{}, err error)

Attr attempts to retrieve the attribute with the given name and return its values as a slice of interfaces. Each value is an interface{} that holds a Go native type that is the best match for the underlying variant.

If the attribute contains IUnknown or IDispatch members, it is the caller's responsibility to release them.

func (*Computer) AttrBool

func (o *Computer) AttrBool(name string) (attr bool, err error)

AttrBool attempts to retrieve the attribute with the given name and return its value as a bool. If the attribute holds more than one value, only the first value is returned.

Any non-bool values contained in the attribute will be ignored.

func (*Computer) AttrBoolSlice

func (o *Computer) AttrBoolSlice(name string) (values []bool, err error)

AttrBoolSlice attempts to retrieve the attribute with the given name and return its values as a slice of bools.

Any non-bool values contained in the attribute will be ommitted.

func (*Computer) AttrBytes

func (o *Computer) AttrBytes(name string) (attr []byte, err error)

AttrBytes attempts to retrieve the attribute with the given name and return its value as a string. If the attribute holds more than one value, only the first value is returned.

Any non-string values contained in the attribute will be ignored.

func (*Computer) AttrBytesSlice

func (o *Computer) AttrBytesSlice(name string) (values [][]byte, err error)

AttrBytesSlice attempts to retrieve the attribute with the given name and return its values as a slice of byte slices.

Any non-byte values contained in the attribute will be ommitted.

func (*Computer) AttrGUID

func (o *Computer) AttrGUID(name string) (attr uuid.UUID, err error)

AttrGUID attempts to retrieve the attribute with the given name and return its value as a GUID in string format. If the attribute holds more than one value, only the first value is returned.

Any non-string values contained in the attribute will be ignored.

func (*Computer) AttrGUIDSlice

func (o *Computer) AttrGUIDSlice(name string) (values []uuid.UUID, err error)

AttrGUIDSlice attempts to retrieve the attribute with the given name and return its values as a slice of GUIDs.

Any non-GUID values contained in the attribute will be ommitted.

Values are returned as-is, without any byte ordering adjustment.

func (*Computer) AttrInt

func (o *Computer) AttrInt(name string) (attr int, err error)

AttrInt attempts to retrieve the attribute with the given name and return its value as an integer. If the attribute holds more than one value, only the first value is returned.

Any non-integer values contained in the attribute will be ignored.

func (*Computer) AttrInt64

func (o *Computer) AttrInt64(name string) (attr int64, err error)

AttrInt64 attempts to retrieve the attribute with the given name and return its value as a 64-bit integer. If the attribute holds more than one value, only the first value is returned.

Any non-integer values contained in the attribute will be ignored.

func (*Computer) AttrInt64Slice

func (o *Computer) AttrInt64Slice(name string) (values []int64, err error)

AttrInt64Slice attempts to retrieve the attribute with the given name and return its values as a slice of 64-bit integers.

Any non-integer values contained in the attribute will be ommitted.

Unsigned integer values will be coerced into signed types.

func (*Computer) AttrIntSlice

func (o *Computer) AttrIntSlice(name string) (values []int, err error)

AttrIntSlice attempts to retrieve the attribute with the given name and return its values as a slice of integers.

Any non-integer values contained in the attribute will be ommitted.

Unsigned integer values will be coerced into signed types.

64-bit integer types will be coerced into integer types, which may overflow the value on 32-bit systems.

func (*Computer) AttrString

func (o *Computer) AttrString(name string) (attr string, err error)

AttrString attempts to retrieve the attribute with the given name and return its value as a string. If the attribute holds more than one value, only the first value is returned.

Any non-string values contained in the attribute will be ignored.

func (*Computer) AttrStringSlice

func (o *Computer) AttrStringSlice(name string) (values []string, err error)

AttrStringSlice attempts to retrieve the attribute with the given name and return its values as a slice of strings.

Any non-string values contained in the attribute will be ommitted.

func (*Computer) Class

func (o *Computer) Class() (class string, err error)

Class retrieves the class of the object.

func (*Computer) Close

func (c *Computer) Close()

Close will release resources consumed by the computer. It should be called when the computer is no longer needed.

func (*Computer) GUID

func (o *Computer) GUID() (guid uuid.UUID, err error)

GUID retrieves the globally unique identifier of the object.

func (*Computer) ID

func (c *Computer) ID() (id string, err error)

ID retrieves the ID of the computer.

func (*Computer) Name

func (o *Computer) Name() (name string, err error)

Name retrieves the name of the object.

func (*Computer) OperatingSystem

func (c *Computer) OperatingSystem() (kind string, err error)

OperatingSystem retrieves the operating system of the computer.

func (*Computer) Parent

func (o *Computer) Parent() (path string, err error)

Parent retrieves the fully qualified path of the object's parent.

func (*Computer) Path

func (o *Computer) Path() (path string, err error)

Path retrieves the fully qualified path of the object.

func (*Computer) Pull

func (o *Computer) Pull(attrs ...string) (err error)

Pull causes the given list of attributes to be retrieved from the underlying LDAP data store. The retrieved attributes will be cached.

Subsequent calls to the attr retrieval functions will return the cached values.

func (*Computer) Schema

func (o *Computer) Schema() (path string, err error)

Schema retrieves the fully qualified path of the object's schema class object.

func (*Computer) Site

func (c *Computer) Site() (site string, err error)

Site retrieves the site of the computer.

func (*Computer) ToComputer

func (o *Computer) ToComputer() (c *Computer, err error)

ToComputer attempts to acquire a computer interface for the object.

func (*Computer) ToContainer

func (o *Computer) ToContainer() (c *Container, err error)

ToContainer attempts to acquire a container interface for the object.

func (*Computer) ToGroup

func (o *Computer) ToGroup() (g *Group, err error)

ToGroup attempts to acquire a group interface for the object.

type Container

type Container struct {
	// contains filtered or unexported fields
}

Container provides access to Active Directory container objects.

func NewContainer

func NewContainer(iface *api.IADsContainer) *Container

NewContainer returns a container that manages the given COM interface.

func OpenContainer

func OpenContainer(path string) (container *Container, err error)

OpenContainer opens an ADSI container with the given path. It creates an ephemeral local client and uses it to open the requested container. The connection is made using the security context of the application and the default client flags specifying that it be encrypted and read-only.

OpenContainer returns the ADSI container as a Container type, which provides an idiomatic go wrapper around the underlying component object model IADsContainer interface.

If the returned directory object does not implement the IADsContainer interface an error is returned.

The returned container consumes resources until it is closed. It is the caller's responsibilty to call Close on the returned container when it is no longer needed.

func OpenContainerSC

func OpenContainerSC(path, user, password string, flags uint32) (container *Container, err error)

OpenContainerSC opens an ADSI container with the given path. Most users will use OpenContainer instead. It creates an ephemeral local client and uses it to open the requested container.

When provided, the username and password are used to establish a security context for the connection. When they are not provided the existing security context of the application is used instead. The provided flags will be used to make the connection.

OpenContainerSC returns the ADSI container as a Container type, which provides an idiomatic go wrapper around the underlying component object model IADsContainer interface.

If the returned directory object does not implement the IADsContainer interface an error is returned.

The returned container consumes resources until it is closed. It is the caller's responsibilty to call Close on the returned container when it is no longer needed.

func (*Container) Children

func (c *Container) Children() (iter *ObjectIter, err error)

Children returns an object iterator that provides access to the immediate children of the container.

func (*Container) Close

func (c *Container) Close()

Close will release resources consumed by the container. It should be called when the container is no longer needed.

func (*Container) Container

func (c *Container) Container(class, name string) (container *Container, err error)

Container returns a descendant container with the given class and relative name.

If a class is not provided then the first item matching the relative name will be returned regardless of its class.

func (*Container) Filter

func (c *Container) Filter() (filter []string, err error)

Filter returns the current filter of the container.

func (*Container) Object

func (c *Container) Object(class, name string) (obj *Object, err error)

Object returns a descendant object with the given class and relative name.

If a class is not provided then the first item matching the relative name will be returned regardless of its class.

func (*Container) SetFilter

func (c *Container) SetFilter(filter ...string) (err error)

SetFilter set the filter for the container.

func (*Container) ToObject

func (c *Container) ToObject() (o *Object, err error)

ToObject attempts to acquire an object interface for the container.

type Group

type Group struct {
	// contains filtered or unexported fields
}

Group provides access to Active Directory groups.

func NewGroup

func NewGroup(iface *api.IADsGroup) *Group

NewGroup returns a group that manages the given COM interface.

func (*Group) Attr

func (o *Group) Attr(name string) (values []interface{}, err error)

Attr attempts to retrieve the attribute with the given name and return its values as a slice of interfaces. Each value is an interface{} that holds a Go native type that is the best match for the underlying variant.

If the attribute contains IUnknown or IDispatch members, it is the caller's responsibility to release them.

func (*Group) AttrBool

func (o *Group) AttrBool(name string) (attr bool, err error)

AttrBool attempts to retrieve the attribute with the given name and return its value as a bool. If the attribute holds more than one value, only the first value is returned.

Any non-bool values contained in the attribute will be ignored.

func (*Group) AttrBoolSlice

func (o *Group) AttrBoolSlice(name string) (values []bool, err error)

AttrBoolSlice attempts to retrieve the attribute with the given name and return its values as a slice of bools.

Any non-bool values contained in the attribute will be ommitted.

func (*Group) AttrBytes

func (o *Group) AttrBytes(name string) (attr []byte, err error)

AttrBytes attempts to retrieve the attribute with the given name and return its value as a string. If the attribute holds more than one value, only the first value is returned.

Any non-string values contained in the attribute will be ignored.

func (*Group) AttrBytesSlice

func (o *Group) AttrBytesSlice(name string) (values [][]byte, err error)

AttrBytesSlice attempts to retrieve the attribute with the given name and return its values as a slice of byte slices.

Any non-byte values contained in the attribute will be ommitted.

func (*Group) AttrGUID

func (o *Group) AttrGUID(name string) (attr uuid.UUID, err error)

AttrGUID attempts to retrieve the attribute with the given name and return its value as a GUID in string format. If the attribute holds more than one value, only the first value is returned.

Any non-string values contained in the attribute will be ignored.

func (*Group) AttrGUIDSlice

func (o *Group) AttrGUIDSlice(name string) (values []uuid.UUID, err error)

AttrGUIDSlice attempts to retrieve the attribute with the given name and return its values as a slice of GUIDs.

Any non-GUID values contained in the attribute will be ommitted.

Values are returned as-is, without any byte ordering adjustment.

func (*Group) AttrInt

func (o *Group) AttrInt(name string) (attr int, err error)

AttrInt attempts to retrieve the attribute with the given name and return its value as an integer. If the attribute holds more than one value, only the first value is returned.

Any non-integer values contained in the attribute will be ignored.

func (*Group) AttrInt64

func (o *Group) AttrInt64(name string) (attr int64, err error)

AttrInt64 attempts to retrieve the attribute with the given name and return its value as a 64-bit integer. If the attribute holds more than one value, only the first value is returned.

Any non-integer values contained in the attribute will be ignored.

func (*Group) AttrInt64Slice

func (o *Group) AttrInt64Slice(name string) (values []int64, err error)

AttrInt64Slice attempts to retrieve the attribute with the given name and return its values as a slice of 64-bit integers.

Any non-integer values contained in the attribute will be ommitted.

Unsigned integer values will be coerced into signed types.

func (*Group) AttrIntSlice

func (o *Group) AttrIntSlice(name string) (values []int, err error)

AttrIntSlice attempts to retrieve the attribute with the given name and return its values as a slice of integers.

Any non-integer values contained in the attribute will be ommitted.

Unsigned integer values will be coerced into signed types.

64-bit integer types will be coerced into integer types, which may overflow the value on 32-bit systems.

func (*Group) AttrString

func (o *Group) AttrString(name string) (attr string, err error)

AttrString attempts to retrieve the attribute with the given name and return its value as a string. If the attribute holds more than one value, only the first value is returned.

Any non-string values contained in the attribute will be ignored.

func (*Group) AttrStringSlice

func (o *Group) AttrStringSlice(name string) (values []string, err error)

AttrStringSlice attempts to retrieve the attribute with the given name and return its values as a slice of strings.

Any non-string values contained in the attribute will be ommitted.

func (*Group) Class

func (o *Group) Class() (class string, err error)

Class retrieves the class of the object.

func (*Group) Close

func (g *Group) Close()

Close will release resources consumed by the group. It should be called when the group is no longer needed.

func (*Group) Description

func (g *Group) Description() (desc string, err error)

Description retrieves the description of the group.

func (*Group) GUID

func (o *Group) GUID() (guid uuid.UUID, err error)

GUID retrieves the globally unique identifier of the object.

func (*Group) Members

func (g *Group) Members() (m *Members, err error)

Members returns a membership that provides access to the members of the group.

func (*Group) Name

func (o *Group) Name() (name string, err error)

Name retrieves the name of the object.

func (*Group) Parent

func (o *Group) Parent() (path string, err error)

Parent retrieves the fully qualified path of the object's parent.

func (*Group) Path

func (o *Group) Path() (path string, err error)

Path retrieves the fully qualified path of the object.

func (*Group) Pull

func (o *Group) Pull(attrs ...string) (err error)

Pull causes the given list of attributes to be retrieved from the underlying LDAP data store. The retrieved attributes will be cached.

Subsequent calls to the attr retrieval functions will return the cached values.

func (*Group) Schema

func (o *Group) Schema() (path string, err error)

Schema retrieves the fully qualified path of the object's schema class object.

func (*Group) ToComputer

func (o *Group) ToComputer() (c *Computer, err error)

ToComputer attempts to acquire a computer interface for the object.

func (*Group) ToContainer

func (o *Group) ToContainer() (c *Container, err error)

ToContainer attempts to acquire a container interface for the object.

func (*Group) ToGroup

func (o *Group) ToGroup() (g *Group, err error)

ToGroup attempts to acquire a group interface for the object.

type Members

type Members struct {
	// contains filtered or unexported fields
}

Members provides access to group membership.

func NewMembers

func NewMembers(iface *api.IADsMembers) *Members

NewMembers returns a membership that manages the given COM interface.

func (*Members) Close

func (m *Members) Close()

Close will release resources consumed by the membership. It should be called when the membership is no longer needed.

func (*Members) Filter

func (m *Members) Filter() (filter []string, err error)

Filter returns the current filter of the membership.

func (*Members) Iter

func (m *Members) Iter() (iter *ObjectIter, err error)

Iter returns an object iterator that provides access to the members of the group.

func (*Members) SetFilter

func (m *Members) SetFilter(filter ...string) (err error)

SetFilter set the filter for the mebership.

type Object

type Object struct {
	// contains filtered or unexported fields
}

Object provides access to Active Directory objects.

func NewObject

func NewObject(iface *api.IADs) *Object

NewObject returns an object that manages the given COM interface.

func Open

func Open(path string) (obj *Object, err error)

Open opens an ADSI object with the given path. It creates an ephemeral local client and uses it to open the requested object. The connection is made using the security context of the application and the default client flags specifying that it be encrypted and read-only.

Open returns the ADSI object as an Object type, which provides an idiomatic go wrapper around the underlying component object model IADs interface.

If the requested ADSI object does not implement the IADs interface an error is returned.

The returned object consumes resources until it is closed. It is the caller's responsibilty to call Close on the returned object when it is no longer needed.

func OpenSC

func OpenSC(path, user, password string, flags uint32) (obj *Object, err error)

OpenSC opens an ADSI object with the given path. Most users will use Open instead. It creates an ephemeral local client and uses it to open the requested object.

When provided, the username and password are used to establish a security context for the connection. When they are not provided the existing security context of the application is used instead. The provided flags will be used to make the connection.

OpenSC returns the ADSI object as an Object type, which provides an idiomatic go wrapper around the underlying component object model IADs interface.

If the requested ADSI object does not implement the IADs interface an error is returned.

The returned object consumes resources until it is closed. It is the caller's responsibilty to call Close on the returned object when it is no longer needed.

func (*Object) Attr

func (o *Object) Attr(name string) (values []interface{}, err error)

Attr attempts to retrieve the attribute with the given name and return its values as a slice of interfaces. Each value is an interface{} that holds a Go native type that is the best match for the underlying variant.

If the attribute contains IUnknown or IDispatch members, it is the caller's responsibility to release them.

func (*Object) AttrBool

func (o *Object) AttrBool(name string) (attr bool, err error)

AttrBool attempts to retrieve the attribute with the given name and return its value as a bool. If the attribute holds more than one value, only the first value is returned.

Any non-bool values contained in the attribute will be ignored.

func (*Object) AttrBoolSlice

func (o *Object) AttrBoolSlice(name string) (values []bool, err error)

AttrBoolSlice attempts to retrieve the attribute with the given name and return its values as a slice of bools.

Any non-bool values contained in the attribute will be ommitted.

func (*Object) AttrBytes

func (o *Object) AttrBytes(name string) (attr []byte, err error)

AttrBytes attempts to retrieve the attribute with the given name and return its value as a string. If the attribute holds more than one value, only the first value is returned.

Any non-string values contained in the attribute will be ignored.

func (*Object) AttrBytesSlice

func (o *Object) AttrBytesSlice(name string) (values [][]byte, err error)

AttrBytesSlice attempts to retrieve the attribute with the given name and return its values as a slice of byte slices.

Any non-byte values contained in the attribute will be ommitted.

func (*Object) AttrGUID

func (o *Object) AttrGUID(name string) (attr uuid.UUID, err error)

AttrGUID attempts to retrieve the attribute with the given name and return its value as a GUID in string format. If the attribute holds more than one value, only the first value is returned.

Any non-string values contained in the attribute will be ignored.

func (*Object) AttrGUIDSlice

func (o *Object) AttrGUIDSlice(name string) (values []uuid.UUID, err error)

AttrGUIDSlice attempts to retrieve the attribute with the given name and return its values as a slice of GUIDs.

Any non-GUID values contained in the attribute will be ommitted.

Values are returned as-is, without any byte ordering adjustment.

func (*Object) AttrInt

func (o *Object) AttrInt(name string) (attr int, err error)

AttrInt attempts to retrieve the attribute with the given name and return its value as an integer. If the attribute holds more than one value, only the first value is returned.

Any non-integer values contained in the attribute will be ignored.

func (*Object) AttrInt64

func (o *Object) AttrInt64(name string) (attr int64, err error)

AttrInt64 attempts to retrieve the attribute with the given name and return its value as a 64-bit integer. If the attribute holds more than one value, only the first value is returned.

Any non-integer values contained in the attribute will be ignored.

func (*Object) AttrInt64Slice

func (o *Object) AttrInt64Slice(name string) (values []int64, err error)

AttrInt64Slice attempts to retrieve the attribute with the given name and return its values as a slice of 64-bit integers.

Any non-integer values contained in the attribute will be ommitted.

Unsigned integer values will be coerced into signed types.

func (*Object) AttrIntSlice

func (o *Object) AttrIntSlice(name string) (values []int, err error)

AttrIntSlice attempts to retrieve the attribute with the given name and return its values as a slice of integers.

Any non-integer values contained in the attribute will be ommitted.

Unsigned integer values will be coerced into signed types.

64-bit integer types will be coerced into integer types, which may overflow the value on 32-bit systems.

func (*Object) AttrString

func (o *Object) AttrString(name string) (attr string, err error)

AttrString attempts to retrieve the attribute with the given name and return its value as a string. If the attribute holds more than one value, only the first value is returned.

Any non-string values contained in the attribute will be ignored.

func (*Object) AttrStringSlice

func (o *Object) AttrStringSlice(name string) (values []string, err error)

AttrStringSlice attempts to retrieve the attribute with the given name and return its values as a slice of strings.

Any non-string values contained in the attribute will be ommitted.

func (*Object) Class

func (o *Object) Class() (class string, err error)

Class retrieves the class of the object.

func (*Object) Close

func (o *Object) Close()

Close will release resources consumed by the object. It should be called when the object is no longer needed.

func (*Object) GUID

func (o *Object) GUID() (guid uuid.UUID, err error)

GUID retrieves the globally unique identifier of the object.

func (*Object) Name

func (o *Object) Name() (name string, err error)

Name retrieves the name of the object.

func (*Object) Parent

func (o *Object) Parent() (path string, err error)

Parent retrieves the fully qualified path of the object's parent.

func (*Object) Path

func (o *Object) Path() (path string, err error)

Path retrieves the fully qualified path of the object.

func (*Object) Pull

func (o *Object) Pull(attrs ...string) (err error)

Pull causes the given list of attributes to be retrieved from the underlying LDAP data store. The retrieved attributes will be cached.

Subsequent calls to the attr retrieval functions will return the cached values.

func (*Object) Schema

func (o *Object) Schema() (path string, err error)

Schema retrieves the fully qualified path of the object's schema class object.

func (*Object) ToComputer

func (o *Object) ToComputer() (c *Computer, err error)

ToComputer attempts to acquire a computer interface for the object.

func (*Object) ToContainer

func (o *Object) ToContainer() (c *Container, err error)

ToContainer attempts to acquire a container interface for the object.

func (*Object) ToGroup

func (o *Object) ToGroup() (g *Group, err error)

ToGroup attempts to acquire a group interface for the object.

type ObjectIter

type ObjectIter struct {
	// contains filtered or unexported fields
}

ObjectIter provides an iterator for a set of objects.

func NewObjectIter

func NewObjectIter(enumerator *ole.IEnumVARIANT) *ObjectIter

NewObjectIter returns an object iterator that provides access to the objects contained in the given enumerator.

func (*ObjectIter) Close

func (iter *ObjectIter) Close()

Close will release resources consumed by the iterator. It should be called when the iterator is no longer needed.

func (*ObjectIter) Next

func (iter *ObjectIter) Next() (obj *Object, err error)

Next moves the iterator to the next object and returns a pointer to it. If it has reached the end of the set it will return io.EOF. It the iterator has already been closed it will return ErrClosed.

FIXME: Make sure that io.EOF is being returned as expected. We might have to intercept an internal error.

type User

type User struct {
	// contains filtered or unexported fields
}

User provides access to Active Directory users.

func NewUser

func NewUser(iface *api.IADsUser) *User

NewUser returns a user that manages the given COM interface.

func (*User) Attr

func (o *User) Attr(name string) (values []interface{}, err error)

Attr attempts to retrieve the attribute with the given name and return its values as a slice of interfaces. Each value is an interface{} that holds a Go native type that is the best match for the underlying variant.

If the attribute contains IUnknown or IDispatch members, it is the caller's responsibility to release them.

func (*User) AttrBool

func (o *User) AttrBool(name string) (attr bool, err error)

AttrBool attempts to retrieve the attribute with the given name and return its value as a bool. If the attribute holds more than one value, only the first value is returned.

Any non-bool values contained in the attribute will be ignored.

func (*User) AttrBoolSlice

func (o *User) AttrBoolSlice(name string) (values []bool, err error)

AttrBoolSlice attempts to retrieve the attribute with the given name and return its values as a slice of bools.

Any non-bool values contained in the attribute will be ommitted.

func (*User) AttrBytes

func (o *User) AttrBytes(name string) (attr []byte, err error)

AttrBytes attempts to retrieve the attribute with the given name and return its value as a string. If the attribute holds more than one value, only the first value is returned.

Any non-string values contained in the attribute will be ignored.

func (*User) AttrBytesSlice

func (o *User) AttrBytesSlice(name string) (values [][]byte, err error)

AttrBytesSlice attempts to retrieve the attribute with the given name and return its values as a slice of byte slices.

Any non-byte values contained in the attribute will be ommitted.

func (*User) AttrGUID

func (o *User) AttrGUID(name string) (attr uuid.UUID, err error)

AttrGUID attempts to retrieve the attribute with the given name and return its value as a GUID in string format. If the attribute holds more than one value, only the first value is returned.

Any non-string values contained in the attribute will be ignored.

func (*User) AttrGUIDSlice

func (o *User) AttrGUIDSlice(name string) (values []uuid.UUID, err error)

AttrGUIDSlice attempts to retrieve the attribute with the given name and return its values as a slice of GUIDs.

Any non-GUID values contained in the attribute will be ommitted.

Values are returned as-is, without any byte ordering adjustment.

func (*User) AttrInt

func (o *User) AttrInt(name string) (attr int, err error)

AttrInt attempts to retrieve the attribute with the given name and return its value as an integer. If the attribute holds more than one value, only the first value is returned.

Any non-integer values contained in the attribute will be ignored.

func (*User) AttrInt64

func (o *User) AttrInt64(name string) (attr int64, err error)

AttrInt64 attempts to retrieve the attribute with the given name and return its value as a 64-bit integer. If the attribute holds more than one value, only the first value is returned.

Any non-integer values contained in the attribute will be ignored.

func (*User) AttrInt64Slice

func (o *User) AttrInt64Slice(name string) (values []int64, err error)

AttrInt64Slice attempts to retrieve the attribute with the given name and return its values as a slice of 64-bit integers.

Any non-integer values contained in the attribute will be ommitted.

Unsigned integer values will be coerced into signed types.

func (*User) AttrIntSlice

func (o *User) AttrIntSlice(name string) (values []int, err error)

AttrIntSlice attempts to retrieve the attribute with the given name and return its values as a slice of integers.

Any non-integer values contained in the attribute will be ommitted.

Unsigned integer values will be coerced into signed types.

64-bit integer types will be coerced into integer types, which may overflow the value on 32-bit systems.

func (*User) AttrString

func (o *User) AttrString(name string) (attr string, err error)

AttrString attempts to retrieve the attribute with the given name and return its value as a string. If the attribute holds more than one value, only the first value is returned.

Any non-string values contained in the attribute will be ignored.

func (*User) AttrStringSlice

func (o *User) AttrStringSlice(name string) (values []string, err error)

AttrStringSlice attempts to retrieve the attribute with the given name and return its values as a slice of strings.

Any non-string values contained in the attribute will be ommitted.

func (*User) Class

func (o *User) Class() (class string, err error)

Class retrieves the class of the object.

func (*User) Close

func (u *User) Close()

Close will release resources consumed by the user. It should be called when the user is no longer needed.

func (*User) GUID

func (o *User) GUID() (guid uuid.UUID, err error)

GUID retrieves the globally unique identifier of the object.

func (*User) Name

func (o *User) Name() (name string, err error)

Name retrieves the name of the object.

func (*User) Parent

func (o *User) Parent() (path string, err error)

Parent retrieves the fully qualified path of the object's parent.

func (*User) Path

func (o *User) Path() (path string, err error)

Path retrieves the fully qualified path of the object.

func (*User) Pull

func (o *User) Pull(attrs ...string) (err error)

Pull causes the given list of attributes to be retrieved from the underlying LDAP data store. The retrieved attributes will be cached.

Subsequent calls to the attr retrieval functions will return the cached values.

func (*User) Schema

func (o *User) Schema() (path string, err error)

Schema retrieves the fully qualified path of the object's schema class object.

func (*User) ToComputer

func (o *User) ToComputer() (c *Computer, err error)

ToComputer attempts to acquire a computer interface for the object.

func (*User) ToContainer

func (o *User) ToContainer() (c *Container, err error)

ToContainer attempts to acquire a container interface for the object.

func (*User) ToGroup

func (o *User) ToGroup() (g *Group, err error)

ToGroup attempts to acquire a group interface for the object.

Directories

Path Synopsis
cmd
Package comclsid provides component object model class identifiers for active directory domain services.
Package comclsid provides component object model class identifiers for active directory domain services.
Package comiid provides component object model interface identifiers for active directory domain services.
Package comiid provides component object model interface identifiers for active directory domain services.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL