Closed ghost closed 1 year ago
this does it:
package main
import (
"flag"
"github.com/go-ldap/ldap/v3"
)
func main() {
var password string
flag.StringVar(&password, "p", "", "password")
var username string
flag.StringVar(&username, "u", "", "username")
flag.Parse()
if password != "" {
conn, err := ldap.Dial("tcp", "127.0.0.1:389")
if err != nil {
panic(err)
}
defer conn.Close()
if err = conn.Bind(username, password); err != nil {
panic(err)
}
req := ldap.NewAddRequest(
"CN=Hello World,OU=Users,DC=TA,DC=lan", nil,
)
req.Attribute("objectClass", []string{"user"})
if err := conn.Add(req); err != nil {
panic(err)
}
} else {
flag.Usage()
}
}
is it possible to create a new user in Active Directory using this package? I check this:
https://github.com/go-ldap/ldap/blob/master/v3/examples_test.go
but didn't see an example