本文整理汇总了Golang中github.com/vjeantet/ldapserver.Message.GetBindRequest方法的典型用法代码示例。如果您正苦于以下问题:Golang Message.GetBindRequest方法的具体用法?Golang Message.GetBindRequest怎么用?Golang Message.GetBindRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/vjeantet/ldapserver.Message
的用法示例。
在下文中一共展示了Message.GetBindRequest方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: handleBind
// handleBind return Success if login == mysql
func handleBind(w ldap.ResponseWriter, m *ldap.Message) {
r := m.GetBindRequest()
res := ldap.NewBindResponse(ldap.LDAPResultSuccess)
if string(r.Name()) == "login" {
w.Write(res)
return
}
log.Printf("Bind failed User=%s, Pass=%s", string(r.Name()), string(r.AuthenticationSimple()))
res.SetResultCode(ldap.LDAPResultInvalidCredentials)
res.SetDiagnosticMessage("invalid credentials")
w.Write(res)
}
示例2: handleBind
func handleBind(w ldap.ResponseWriter, m *ldap.Message) {
r := m.GetBindRequest()
res := ldap.NewBindResponse(ldap.LDAPResultSuccess)
if string(r.GetLogin()) == "myLogin" {
w.Write(res)
return
}
log.Printf("Bind failed User=%s, Pass=%s", string(r.GetLogin()), string(r.GetPassword()))
res.ResultCode = ldap.LDAPResultInvalidCredentials
res.DiagnosticMessage = "invalid credentials"
w.Write(res)
}
示例3: handleBind
func (t *testLDAPServer) handleBind(w ldapserver.ResponseWriter, m *ldapserver.Message) {
r := m.GetBindRequest()
// Record the request
t.BindRequests = append(t.BindRequests, r)
dn := string(r.GetLogin())
password := string(r.GetPassword())
// Require a non-empty username and password
if len(dn) == 0 || len(password) == 0 {
w.Write(ldapserver.NewBindResponse(ldapserver.LDAPResultUnwillingToPerform))
return
}
// Require the DN to be found and the password to match
expectedPassword, ok := t.Passwords[dn]
if !ok || expectedPassword != password {
w.Write(ldapserver.NewBindResponse(ldapserver.LDAPResultInvalidCredentials))
return
}
w.Write(ldapserver.NewBindResponse(ldapserver.LDAPResultSuccess))
}