---
name: "Memcached::libmemcached::memcached_sasl"
section: "3pm"
platform: "linux"
package: "libmemcached-libmemcached-perl"
version: "1.001801+dfsg-5+b2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Memcached::libmemcached::memcached_sasl"
---

# Memcached::libmemcached::memcached\_sasl(3pm)

SASL support

## NAME

memcached\_set\_sasl\_callbacks, memcached\_get\_sasl\_callbacks, memcached\_sasl\_set\_auth\_data, memcached\_destroy\_sasl\_auth\_data - SASL support

## LIBRARY

C Client Library for memcached (libmemcached, -lmemcached)

## SYNOPSIS

```
  #include <memcached.h>
  void memcached_set_sasl_callbacks(memcached_st *ptr,
                                    const sasl_callback_t *callbacks)
  const sasl_callback_t *memcached_get_sasl_callbacks(memcached_st *ptr)
  memcached_return memcached_set_sasl_auth_data(memcached_st *ptr,
                                                const char *username,
                                                const char *password)
  memcached_return memcached_destroy_sasl_auth_data(memcached_st *ptr)
```

## DESCRIPTION

[**libmemcached**(3)](/libmemcached/3.md) allows you to plug in your own callbacks function used by libsasl to perform SASL authentication.

Please note that SASL requires the memcached binary protocol, and you have to specify the callbacks before you connect to the server.

**memcached\_set\_sasl\_auth\_data()** is a helper function for you defining the basic functionality for you, but it will store the username and password in memory. If you choose to use this method you have to call memcached\_destroy\_sasl\_auth\_data before calling memcached\_free to avoid a memory leak. You should NOT call memcached\_destroy\_sasl\_auth\_data if you specify your own callback function with **memcached\_set\_sasl\_callbacks()**.

You as a client user have to initialize libsasl by using sasl\_client\_init before enabling it in libmemcached, and you have to shut down libsasl by calling **sasl\_done()** when you are done using SASL from libmemcached.

## RETURN

**memcached\_get\_sasl\_callbacks()** returns the callbacks currently used by this memcached handle. **memcached\_get\_sasl\_set\_auth\_data()** returns MEMCACHED\_SUCCESS upon success.

## HOME

To find out more information please check: \<http://libmemcached.org/\>

## AUTHOR

Trond Norbye, \<trond.norbye@gmail.com\>

## SEE ALSO

[**memcached**(1)](/memcached/1.md) [**libmemcached**(3)](/libmemcached/3.md)
