** Copyright (C) 2001-2025 Zabbix SIA
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
"golang.org/x/sys/windows"
"golang.zabbix.com/sdk/zbxerr"
func (p *Plugin) exportOwner(params []string) (result interface{}, err error) {
if params[2] != "name" && params[2] != "id" {
return nil, fmt.Errorf("Invalid third parameter: %s.", params[2])
if params[1] != "" && params[1] != ownertype {
return nil, fmt.Errorf("Invalid second parameter: %s.", params[1])
if path = params[0]; path == "" {
return nil, errors.New("Invalid first parameter.")
return nil, zbxerr.ErrorTooFewParameters
return nil, zbxerr.ErrorTooManyParameters
sd, err := windows.GetNamedSecurityInfo(path, windows.SE_FILE_OBJECT, windows.OWNER_SECURITY_INFORMATION)
return nil, zbxerr.New(fmt.Sprintf("Cannot obtain %s information", path)).Wrap(err)