---
title: "Authentication"
canonical: "https://docs.cuesystem.com/space/CVCHELP/555090070/Authentication"
format: markdown
---
> Macro (toc)

---

# LDAPAuthenticate

This function is capable of authenticating credentials (user name and password) by LDAP (Lightweight Directory Access Protocol) or LDAPS (Secure Lightweight Directory Access Protocol). LDAP/LDAPS is one way of keeping authentication information in a single centralized location. The function supports the LDAPv3 protocol and uses the DIGEST-MD5 authentication mechanism. If credentials have been authenticated on the LDAP server the function returns True. 

#### Syntax 

```visualbasic
Function LDAPAuthenticate(
  serverURL As Text, 
  username As Text, 
  password As Text, 
  Optional timeout As Time := :10.0) 
As Boolean
```

#### Parameters 

serverURL 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> Itthe  is server URL. It must be in the followed format: [protocol://]servername[:port] 

As protocol can be **LDAP **to communicate with the LDAP server or **LDAP **to communicate with the LDAPS server. If the protocol is not specified LDAP protocol is used. As servername can be Ip address or domain name. Port is optional. If the port is not specified, port 389 for LDAP and 636 for LDAPS are used. 

username  

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> It is a user name. 

password  

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> It is a user password. 

timeout 

<u>[Time](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Time)</u> Optional, defaults to 10 seconds. It is the timeout for LDAP operation (conversion domain name to IP address + connection + credentials authentication). 

#### Example 

```visualbasic
// Try to authenticate credentials by LDAP server on IP address  
// "192.168.100.100" and port 3030 

If LDAPAuthenticate("ldap://192.168.100.100:3030", "admin", "xyz") = True Then 
  DebugPrint("Credentials have been authenticated by LDAP server.") 
Else 
  DebugPrint(GetLastError()) 
End If
```

```visualbasic
// Try to authenticate credentials by LDAPS server with domain name  
// mail.example.com. Because the port is not specified so default port for  
// ldaps service (636) is used.  

If LDAPAuthenticate("ldaps://mail.example.com", "admin", "xyz") = True Then 
  DebugPrint("Credentials have been authenticated by LDAPS server.") 
Else 
  DebugPrint(GetLastError()) 
End If 
```

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> This function returns True if credentials have been authenticated by the LDAP server. It returns False if an error occurs. 

The function GetLastError returns the error number. The errors that can happen: <u>[94](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#94)</u>, <u>[226](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#226)</u>, <u>[227](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#227)</u>, <u>[228](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#228)</u>, <u>[229](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#229)</u>.