Active Directory/Search for a user: Difference between revisions

Added Go
(Scala contribution added.)
(Added Go)
Line 89:
end
</lang>
 
=={{header|Go}}==
{{libheader|go-ldap-client}}
<br>
There are a large number of third-party LDAP libraries for Go. This uses one of the simpler ones and the code below is largely taken from the example on its main page.
<lang go>package main
 
import (
"log"
"github.com/jtblin/go-ldap-client"
)
 
func main() {
client := &ldap.LDAPClient{
Base: "dc=example,dc=com",
Host: "ldap.example.com",
Port: 389,
GroupFilter: "(memberUid=%s)",
}
defer client.Close()
err := client.Connect()
if err != nil {
log.Fatalf("Failed to connect : %+v", err)
}
groups, err := client.GetGroupsOfUser("username")
if err != nil {
log.Fatalf("Error getting groups for user %s: %+v", "username", err)
}
log.Printf("Groups: %+v", groups)
}</lang>
 
=={{header|Haskell}}==
9,476

edits