mssqldb

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxPageSize = 100
	MinPageSize = 10
)
View Source
const (
	UserType         = "user"
	DatabaseUserType = "database-user"
)
View Source
const DatabaseRoleType = "database-role"
View Source
const DatabaseType = "database"
View Source
const GroupType = "group"
View Source
const ServerRoleType = "server-role"
View Source
const ServerType = "server"

Variables

View Source
var ErrNoServerPrincipal = errors.New("no server principal found")

Functions

This section is empty.

Types

type Client

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

func New

func New(ctx context.Context, dsn string) (*Client, error)

func (*Client) GetDatabase

func (c *Client) GetDatabase(ctx context.Context, id int64) (*DbModel, error)

func (*Client) GetServer

func (c *Client) GetServer(ctx context.Context) (*ServerModel, error)

func (*Client) GetServerPrincipalForDatabasePrincipal

func (c *Client) GetServerPrincipalForDatabasePrincipal(ctx context.Context, dbName string, principalID int64) (*UserModel, error)

GetServerPrincipalForDatabasePrincipal returns the server principal for a given database user. Returns ErrNoServerPrincipal if no server principal is found.

func (*Client) ListDatabasePermissions

func (c *Client) ListDatabasePermissions(ctx context.Context, dbName string, pager *Pager) ([]*PermissionModel, string, error)

func (*Client) ListDatabaseRolePrincipals

func (c *Client) ListDatabaseRolePrincipals(ctx context.Context, dbName string, databaseRoleID string, pager *Pager) ([]*RolePrincipalModel, string, error)

func (*Client) ListDatabaseRoles

func (c *Client) ListDatabaseRoles(ctx context.Context, dbName string, pager *Pager) ([]*RoleModel, string, error)

func (*Client) ListDatabaseUserPrincipals

func (c *Client) ListDatabaseUserPrincipals(ctx context.Context, dbName string, pager *Pager) ([]*UserModel, string, error)

func (*Client) ListDatabases

func (c *Client) ListDatabases(ctx context.Context, pager *Pager) ([]*DbModel, string, error)

func (*Client) ListGroupPrincipals

func (c *Client) ListGroupPrincipals(ctx context.Context, pager *Pager) ([]*GroupModel, string, error)

func (*Client) ListServerPermissions

func (c *Client) ListServerPermissions(ctx context.Context, pager *Pager) ([]*PermissionModel, string, error)

func (*Client) ListServerRolePrincipals

func (c *Client) ListServerRolePrincipals(ctx context.Context, serverRoleID string, pager *Pager) ([]*RolePrincipalModel, string, error)

func (*Client) ListServerRoles

func (c *Client) ListServerRoles(ctx context.Context, pager *Pager) ([]*RoleModel, string, error)

func (*Client) ListServerUserPrincipals

func (c *Client) ListServerUserPrincipals(ctx context.Context, pager *Pager) ([]*UserModel, string, error)

type DbModel

type DbModel struct {
	ID   int64  `db:"database_id"`
	Name string `db:"name"`
}

type GroupModel

type GroupModel struct {
	ID         string `db:"principal_id"`
	SecurityID string `db:"sid"`
	Name       string `db:"name"`
	Type       string `db:"type_desc"`
}

type Pager

type Pager struct {
	Token string
	Size  int
}

func (*Pager) Parse

func (p *Pager) Parse() (int, int, error)

Parse returns the offset and page size.

type PermissionModel

type PermissionModel struct {
	PrincipalName string `db:"principal_name"`
	PrincipalID   int64  `db:"principal_id"`
	PrincipalType string `db:"principal_type"`
	State         string `db:"state"`
	Permissions   string `db:"perms"`
}

type RoleModel

type RoleModel struct {
	ID         int64  `db:"principal_id"`
	SecurityID string `db:"sid"`
	Name       string `db:"name"`
	Type       string `db:"type_desc"`
}

type RolePrincipalModel

type RolePrincipalModel struct {
	ID   int64  `db:"principal_id"`
	Name string `db:"name"`
	Type string `db:"type"`
}

type ServerModel

type ServerModel struct {
	Name string `db:"ServerName"`
}

type UserModel

type UserModel struct {
	ID         string `db:"principal_id"`
	SecurityID string `db:"sid"`
	Name       string `db:"name"`
	Type       string `db:"type_desc"`
	IsDisabled bool   `db:"is_disabled"`
}

Jump to

Keyboard shortcuts

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