Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create a new user #444

Closed
ghost opened this issue Jun 26, 2023 · 1 comment
Closed

create a new user #444

ghost opened this issue Jun 26, 2023 · 1 comment

Comments

@ghost
Copy link

ghost commented Jun 26, 2023

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

@ghost
Copy link
Author

ghost commented Jun 28, 2023

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()
   }
}

@ghost ghost closed this as completed Jun 28, 2023
@ghost ghost mentioned this issue Jun 28, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants