本文整理汇总了Golang中github.com/bytemine/ldap-crud/slapd.Slapd类的典型用法代码示例。如果您正苦于以下问题:Golang Slapd类的具体用法?Golang Slapd怎么用?Golang Slapd使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Slapd类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestReadAllSubtree
func TestReadAllSubtree(t *testing.T) {
var s = new(slapd.Slapd)
s.Config = &slapd.DefaultConfig
err := s.StartAndInitialize()
if err != nil {
t.Error(err)
}
defer s.Stop()
testReadAllSubtree(t)
}
开发者ID:bytemine,项目名称:ldap-crud,代码行数:12,代码来源:crud_test.go
示例2: TestCreate
func TestCreate(t *testing.T) {
var s = new(slapd.Slapd)
s.Config = &slapd.DefaultConfig
err := s.StartAndInitialize()
defer s.Stop()
if err != nil {
t.Error(err)
}
testCreate(t)
}
开发者ID:bytemine,项目名称:ldap-crud,代码行数:12,代码来源:crud_test.go
示例3: TestDeleteSubtree
func TestDeleteSubtree(t *testing.T) {
var s = new(slapd.Slapd)
s.Config = &slapd.DefaultConfig
err := s.StartAndInitialize()
defer s.Stop()
if err != nil {
t.Error(err)
}
lc := ldap.NewConnection("localhost:9999")
err = lc.Connect()
if err != nil {
t.Error(err)
}
err = lc.Bind(slapd.DefaultConfig.Rootdn.Dn, slapd.DefaultConfig.Rootdn.Password)
if err != nil {
t.Error(err)
}
c := New(lc, "dc=example,dc=com")
err = c.Create(&fritzFoobarPerson)
if err != nil {
t.Error(err)
}
var fritzSubPerson = fritzFoobarPerson
fritzSubPerson.dn = fmt.Sprintf("sn=%v,%v", fritzSubPerson.sn, fritzFoobarPerson.Dn())
err = c.Create(&fritzSubPerson)
if err != nil {
t.Error(err)
}
err = c.DeleteSubtree(&fritzFoobarPerson)
if err != nil {
t.Error(err)
}
err = c.Read(&fritzSubPerson)
if err == nil {
t.Error("object wasn't deleted from ldap")
}
err = c.Read(&fritzFoobarPerson)
if err == nil {
t.Error("object wasn't deleted from ldap")
}
}
开发者ID:bytemine,项目名称:ldap-crud,代码行数:50,代码来源:crud_test.go
示例4: TestPasswd
func TestPasswd(t *testing.T) {
var s = new(slapd.Slapd)
s.Config = &slapd.DefaultConfig
err := s.StartAndInitialize()
defer s.Stop()
if err != nil {
t.Error(err)
}
lc := ldap.NewConnection("localhost:9999")
err = lc.Connect()
if err != nil {
t.Error(err)
}
err = lc.Bind(slapd.DefaultConfig.Rootdn.Dn, slapd.DefaultConfig.Rootdn.Password)
if err != nil {
t.Error(err)
}
c := New(lc, "dc=example,dc=com")
// create test person
err = c.Create(&fritzFoobarPerson)
if err != nil {
t.Error(err)
}
// set password of test person to "foobaz"
err = c.Passwd(&fritzFoobarPerson, "foobaz")
if err != nil {
t.Error(err)
}
c.Close()
lc = ldap.NewConnection("localhost:9999")
err = lc.Connect()
if err != nil {
t.Error(err)
}
// try to login as the test person with password "foobaz"
err = lc.Bind(fritzFoobarPerson.Dn()+","+slapd.DefaultConfig.Suffix.Dn, "foobaz")
if err != nil {
t.Error(err)
}
c = New(lc, "dc=example,dc=com")
// let the test person change its own password to "foobar"
// this needs these acls set in slapd.conf:
// access to attrs=userPassword
// by self write
// by anonymous auth
// by users none
// access to * by * read
err = c.Passwd(nil, "foobar")
if err != nil {
t.Error(err)
}
c.Close()
lc = ldap.NewConnection("localhost:9999")
err = lc.Connect()
if err != nil {
t.Error(err)
}
// try to login as the test person with password "foobar"
err = lc.Bind(fritzFoobarPerson.Dn()+","+slapd.DefaultConfig.Suffix.Dn, "foobar")
if err != nil {
t.Error(err)
}
}
开发者ID:bytemine,项目名称:ldap-crud,代码行数:78,代码来源:crud_test.go
注:本文中的github.com/bytemine/ldap-crud/slapd.Slapd类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论