我想检查给定objectGUID的密码

I want to write a function that searchs a ldap user with objectGuid in GoLang.
I am using ldap as "gopkg.in/ldap.v2" for connecting ldap host.

l,_ :=ldap.Dial("tcp", fmt.Sprintf("%s:%d", host, 389))
defer l.Close()
l.Bind(adminuser, adminpass);
searchRequest := ldap.NewSearchRequest(
    "dc="+strings.Join(strings.Split(domain,"."),",dc="),
    ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 
    0,false,
    "(&(objectclass=person)(objectGUID=???SpecialFormat???))",
    []string{"dn"},
    nil,
)
sr, err := l.Search(searchRequest);
if err!=nil {
    log.Printf("Error %s",err);
}

       userdn := sr.Entries[0].DN; // I need UserDN for checking

       err=l.Bind(userdn, string(pass)) //checking password

My Code is like this.
I want to search a person that have a GUID like "445a1532-08aa-4a10-8a9c-d7f10f574afe".
But i guess, "The ldapsearch request" wants a different format for objectGUID.
How can i convert my GUIDString to needed format.

As far as I know object GUID must be passed to LDAP filters in a different format called Octet String.

The format is simply a mangling of the hexadecimal values contained in the object Guid split as bytes (remember that a byte contains two hex digits).

Example : "b0ae470c-16bc-4019-b455-8c96ec515f55" -> "\0c\47\ae\b0\bc\16\19\40\b4\55\8c\96\ec\51\5f\55"

I've created a simple golang function in the Go Playground for you to play with.

Hope this resolves your issue.