• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang ldap.Message类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/jsimonetti/ldapserv/ldap.Message的典型用法代码示例。如果您正苦于以下问题:Golang Message类的具体用法?Golang Message怎么用?Golang Message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Message类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: Bind

func (l *LdifBackend) Bind(w ldap.ResponseWriter, m *ldap.Message) {
	r := m.GetBindRequest()
	res := ldap.NewBindResponse(ldap.LDAPResultInvalidCredentials)

	l.Log.Debug("Bind", log.Ctx{"authchoice": r.AuthenticationChoice(), "user": r.Name()})
	if r.AuthenticationChoice() == "simple" {
		//search for userdn
		for _, ldif := range l.ldifs {
			if ldif.dn == string(r.Name()) {
				//Check password
				for _, attr := range ldif.attr {

					if attr.name == "userPassword" {
						if string(attr.content) == string(r.AuthenticationSimple()) {
							res.SetResultCode(ldap.LDAPResultSuccess)
							w.Write(res)
							return
						}
						l.Log.Debug("userPassword doesn't match", log.Ctx{"pass": r.Authentication(), "userPassword": attr.content})
						break
					}
				}
				l.Log.Debug("no userPassword found!")
				break
			}
		}
		l.Log.Info("Bind failed", log.Ctx{"user": r.Name(), "pass": r.Authentication()})
		res.SetResultCode(ldap.LDAPResultInvalidCredentials)
		res.SetDiagnosticMessage("invalid credentials")
	} else {
		res.SetResultCode(ldap.LDAPResultUnwillingToPerform)
		res.SetDiagnosticMessage("Authentication choice not supported")
	}
	w.Write(res)
}
开发者ID:jsimonetti,项目名称:ldapserv,代码行数:35,代码来源:bind.go


示例2: Modify

func (l *LdifBackend) Modify(w ldap.ResponseWriter, m *ldap.Message) {
	r := m.GetModifyRequest()
	l.Log.Debug("Modify entry", log.Ctx{"entry": r.Object()})

	for _, change := range r.Changes() {
		modification := change.Modification()
		var operationString string
		switch change.Operation() {
		case ldap.ModifyRequestChangeOperationAdd:
			operationString = "Add"
		case ldap.ModifyRequestChangeOperationDelete:
			operationString = "Delete"
		case ldap.ModifyRequestChangeOperationReplace:
			operationString = "Replace"
		}

		l.Log.Debug("attribute change", log.Ctx{"operation": operationString, "type": modification.Type_()})
		for _, attributeValue := range modification.Vals() {
			l.Log.Debug("value", log.Ctx{"value": attributeValue})
		}

	}

	res := ldap.NewModifyResponse(ldap.LDAPResultSuccess)
	w.Write(res)
}
开发者ID:jsimonetti,项目名称:ldapserv,代码行数:26,代码来源:modify.go


示例3: Abandon

func (d *DebugBackend) Abandon(w ldap.ResponseWriter, m *ldap.Message) {
	r := m.GetAbandonRequest()
	dump(r)
	// retreive the request to abandon, and send a abort signal to it
	if requestToAbandon, ok := m.Client.GetMessageByID(int(r)); ok {
		requestToAbandon.Abandon()
	}
}
开发者ID:jsimonetti,项目名称:ldapserv,代码行数:8,代码来源:abandon.go


示例4: Compare

// The resultCode is set to compareTrue, compareFalse, or an appropriate
// error.  compareTrue indicates that the assertion value in the ava
// Comparerequest field matches a value of the attribute or subtype according to the
// attribute's EQUALITY matching rule.  compareFalse indicates that the
// assertion value in the ava field and the values of the attribute or
// subtype did not match.  Other result codes indicate either that the
// result of the comparison was Undefined, or that
// some error occurred.
func (l *LdifBackend) Compare(w ldap.ResponseWriter, m *ldap.Message) {
	r := m.GetCompareRequest()
	l.Log.Debug("Comparing entry", log.Ctx{"entry": r.Entry(), "name": r.Ava().AttributeDesc(), "value": r.Ava().AssertionValue()})
	//attributes values

	res := ldap.NewCompareResponse(ldap.LDAPResultCompareTrue)

	w.Write(res)
}
开发者ID:jsimonetti,项目名称:ldapserv,代码行数:17,代码来源:compare.go


示例5: Search

func (d *DefaultsBackend) Search(w ldap.ResponseWriter, m *ldap.Message) {
	r := m.GetSearchRequest()
	if r.BaseObject() == "" && r.Scope() == ldap.SearchRequestScopeBaseObject && r.FilterString() == "(objectclass=*)" {
		d.searchDSE(w, m)
		return
	}
	if r.BaseObject() == "o=Pronoc, c=Net" && r.Scope() == ldap.SearchRequestScopeBaseObject {
		d.searchMyCompany(w, m)
	}
}
开发者ID:jsimonetti,项目名称:ldapserv,代码行数:10,代码来源:defaults.go


示例6: searchMyCompany

func (d *DefaultsBackend) searchMyCompany(w ldap.ResponseWriter, m *ldap.Message) {
	r := m.GetSearchRequest()
	d.Log.Debug("SearchMyCompany", log.Ctx{"basedn": r.BaseObject(), "filter": r.Filter(), "filterString": r.FilterString(), "attributes": r.Attributes(), "timeLimit": r.TimeLimit().Int()})

	e := ldap.NewSearchResultEntry(string(r.BaseObject()))
	e.AddAttribute("objectClass", "top", "organizationalUnit")
	w.Write(e)

	res := ldap.NewSearchResultDoneResponse(ldap.LDAPResultSuccess)
	w.Write(res)
}
开发者ID:jsimonetti,项目名称:ldapserv,代码行数:11,代码来源:defaults.go


示例7: Search

func (l *LdifBackend) Search(w ldap.ResponseWriter, m *ldap.Message) {
	r := m.GetSearchRequest()
	// Handle Stop Signal (server stop / client disconnected / Abandoned request....)
	select {
	case <-m.Done:
		l.Log.Debug("Leaving Search... stop signal")
		return
	default:
	}

	l.Log.Debug("Search", log.Ctx{"basedn": r.BaseObject(), "filter": r.Filter(), "filterString": r.FilterString(), "attributes": r.Attributes(), "timeLimit": r.TimeLimit().Int()})

	var entries []message.SearchResultEntry

	for _, ldif := range l.ldifs {
		if strings.ToLower(ldif.dn) == strings.ToLower(string(r.BaseObject())) {
			if m, result := matchesFilter(r.Filter(), ldif); m != true {
				if result != ldap.LDAPResultSuccess {
					res := ldap.NewSearchResultDoneResponse(result)
					w.Write(res)
					//return make([]message.SearchResultEntry, 0), result
					return
				}
				continue
			}
			entry := l.formatEntry(&ldif, r.Attributes())
			entries = append(entries, entry)
			continue
		}
		if strings.HasSuffix(strings.ToLower(ldif.dn), strings.ToLower(string(r.BaseObject()))) {
			if m, result := matchesFilter(r.Filter(), ldif); m != true {
				if result != ldap.LDAPResultSuccess {
					res := ldap.NewSearchResultDoneResponse(result)
					w.Write(res)
					//return make([]message.SearchResultEntry, 0), result
					return
				}
				continue
			}
			entry := l.formatEntry(&ldif, r.Attributes())
			entries = append(entries, entry)
			continue
		}
	}

	for i := 0; i < len(entries); i++ {
		w.Write(entries[i])
	}

	res := ldap.NewSearchResultDoneResponse(ldap.LDAPResultSuccess)
	w.Write(res)
}
开发者ID:jsimonetti,项目名称:ldapserv,代码行数:52,代码来源:search.go


示例8: NotFound

func (l *LdifBackend) NotFound(w ldap.ResponseWriter, r *ldap.Message) {
	switch r.ProtocolOpType() {
	case ldap.ApplicationBindRequest:
		res := ldap.NewBindResponse(ldap.LDAPResultSuccess)
		res.SetDiagnosticMessage("Default binding behavior set to return Success")

		w.Write(res)

	default:
		res := ldap.NewResponse(ldap.LDAPResultUnwillingToPerform)
		res.SetDiagnosticMessage("Operation not implemented by server")
		w.Write(res)
	}
}
开发者ID:jsimonetti,项目名称:ldapserv,代码行数:14,代码来源:notfound.go


示例9: Add

func (l *LdifBackend) Add(w ldap.ResponseWriter, m *ldap.Message) {
	r := m.GetAddRequest()
	// Handle Stop Signal (server stop / client disconnected / Abandoned request....)
	select {
	case <-m.Done:
		l.Log.Debug("Leaving Add... stop signal")
		return
	default:
	}

	l.Log.Debug("Adding entry", log.Ctx{"entry": r.Entry()})

	entry := ldif{dn: string(r.Entry())}

	for _, attribute := range r.Attributes() {
		for _, attributeValue := range attribute.Vals() {
			if isValueBinary([]byte(attributeValue)) {
				value := base64.StdEncoding.EncodeToString([]byte(attributeValue))
				entry.attr = append(entry.attr, attr{name: string(attribute.Type_()), content: []byte(value), atype: ATTR_TYPE_BINARY})
				l.Log.Debug("attribute", log.Ctx{"type": attribute.Type_(), "value": string(value), "atype": "binary"})
			} else {
				entry.attr = append(entry.attr, attr{name: string(attribute.Type_()), content: []byte(attributeValue), atype: ATTR_TYPE_TEXT})
				l.Log.Debug("attribute", log.Ctx{"type": attribute.Type_(), "value": string(attributeValue), "atype": "string"})
			}
		}
	}
	if ok, err := l.saveEntry(entry); ok {
		l.ldifs = append(l.ldifs, entry)
		res := ldap.NewAddResponse(ldap.LDAPResultSuccess)
		w.Write(res)
		return
	} else {
		l.Log.Debug("Add entry error", log.Ctx{"error": err})
	}
	res := ldap.NewAddResponse(ldap.LDAPResultOperationsError)
	w.Write(res)
}
开发者ID:jsimonetti,项目名称:ldapserv,代码行数:37,代码来源:add.go


示例10: searchDSE

func (d *DefaultsBackend) searchDSE(w ldap.ResponseWriter, m *ldap.Message) {
	r := m.GetSearchRequest()

	d.Log.Debug("SearchDSE", log.Ctx{"basedn": r.BaseObject(), "filter": r.Filter(), "filterString": r.FilterString(), "attributes": r.Attributes(), "timeLimit": r.TimeLimit().Int()})

	e := ldap.NewSearchResultEntry("")
	e.AddAttribute("vendorName", "Jeroen Simonetti")
	e.AddAttribute("vendorVersion", "0.0.1")
	e.AddAttribute("objectClass", "top", "extensibleObject")
	e.AddAttribute("supportedLDAPVersion", "3")
	e.AddAttribute("namingContexts", "o=Pronoc, c=Net")
	e.AddAttribute("supportedExtension", "1.3.6.1.4.1.1466.20037")
	// e.AddAttribute("subschemaSubentry", "cn=schema")
	// e.AddAttribute("namingContexts", "ou=system", "ou=schema", "dc=example,dc=com", "ou=config")
	// e.AddAttribute("supportedFeatures", "1.3.6.1.4.1.4203.1.5.1")
	// e.AddAttribute("supportedControl", "2.16.840.1.113730.3.4.3", "1.3.6.1.4.1.4203.1.10.1", "2.16.840.1.113730.3.4.2", "1.3.6.1.4.1.4203.1.9.1.4", "1.3.6.1.4.1.42.2.27.8.5.1", "1.3.6.1.4.1.4203.1.9.1.1", "1.3.6.1.4.1.4203.1.9.1.3", "1.3.6.1.4.1.4203.1.9.1.2", "1.3.6.1.4.1.18060.0.0.1", "2.16.840.1.113730.3.4.7", "1.2.840.113556.1.4.319")
	// e.AddAttribute("supportedExtension", "1.3.6.1.4.1.1466.20036", "1.3.6.1.4.1.4203.1.11.1", "1.3.6.1.4.1.18060.0.1.5", "1.3.6.1.4.1.18060.0.1.3", "1.3.6.1.4.1.1466.20037")
	// e.AddAttribute("supportedSASLMechanisms", "NTLM", "GSSAPI", "GSS-SPNEGO", "CRAM-MD5", "SIMPLE", "DIGEST-MD5")
	// e.AddAttribute("entryUUID", "f290425c-8272-4e62-8a67-92b06f38dbf5")
	w.Write(e)

	res := ldap.NewSearchResultDoneResponse(ldap.LDAPResultSuccess)
	w.Write(res)
}
开发者ID:jsimonetti,项目名称:ldapserv,代码行数:24,代码来源:defaults.go


示例11: Delete

func (d *DebugBackend) Delete(w ldap.ResponseWriter, m *ldap.Message) {
	r := m.GetDeleteRequest()
	dump(r)
	res := ldap.NewDeleteResponse(ldap.LDAPResultSuccess)
	w.Write(res)
}
开发者ID:jsimonetti,项目名称:ldapserv,代码行数:6,代码来源:delete.go


示例12: Extended

func (d *DebugBackend) Extended(w ldap.ResponseWriter, m *ldap.Message) {
	r := m.GetExtendedRequest()
	dump(r)
	res := ldap.NewExtendedResponse(ldap.LDAPResultSuccess)
	w.Write(res)
}
开发者ID:jsimonetti,项目名称:ldapserv,代码行数:6,代码来源:extended.go


示例13: ModifyDN

func (d *DebugBackend) ModifyDN(w ldap.ResponseWriter, m *ldap.Message) {
	r := m.GetModifyDNRequest()
	dump(r)
	res := ldap.NewModifyResponse(ldap.LDAPResultSuccess)
	w.Write(res)
}
开发者ID:jsimonetti,项目名称:ldapserv,代码行数:6,代码来源:modifydn.go


示例14: Extended

func (d *DefaultsBackend) Extended(w ldap.ResponseWriter, m *ldap.Message) {
	r := m.GetExtendedRequest()
	if r.RequestName() == ldap.NoticeOfStartTLS {
		d.startTLS(w, m)
	}
}
开发者ID:jsimonetti,项目名称:ldapserv,代码行数:6,代码来源:defaults.go



注:本文中的github.com/jsimonetti/ldapserv/ldap.Message类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang ldap.ResponseWriter类代码示例发布时间:2022-05-23
下一篇:
Golang sparta.Widget类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap