fix: misc bug fixes. add usage and event log API

This commit is contained in:
Qiu Jian
2019-05-17 13:54:29 +08:00
parent 2efc5e641e
commit dd13a991c0
19 changed files with 270 additions and 27 deletions
+19 -1
View File
@@ -26,6 +26,7 @@ func init() {
Base string `help:"base DN, e.g. OU=tech,DC=example,DC=com"`
Objectclass string `help:"objectclass, e.g. organizationalPerson"`
Search []string `help:"search conditions, in format of field:value"`
Field []string `help:"retrieve field info"`
}
shellutils.R(&LdapSearchOptions{}, "search", "search ldap", func(cli *ldaputils.SLDAPClient, args *LdapSearchOptions) error {
search := make(map[string]string)
@@ -36,7 +37,7 @@ func init() {
}
search[s[:colonPos]] = s[(colonPos + 1):]
}
entries, err := cli.Search(args.Base, args.Objectclass, search, nil)
entries, err := cli.Search(args.Base, args.Objectclass, search, args.Field)
if err != nil {
return err
}
@@ -45,4 +46,21 @@ func init() {
}
return nil
})
type LdapAuthOptions struct {
Base string `help:"base DN, e.g. OU=tech,DC=example,DC=com"`
Objectclass string `help:"objectclass, e.g. organizationalPerson"`
ATTR string `help:"account attribute name"`
ACCOUNT string `help:"account name to auth"`
PASSWORD string `help:"Password to auth"`
Field []string `help:"retrieve field info"`
}
shellutils.R(&LdapAuthOptions{}, "auth", "authenticate against ldap", func(cli *ldaputils.SLDAPClient, args *LdapAuthOptions) error {
entry, err := cli.Authenticate(args.Base, args.Objectclass, args.ATTR, args.ACCOUNT, args.PASSWORD, args.Field)
if err != nil {
return err
}
entry.PrettyPrint(2)
return nil
})
}