Active Directory/Connect: Difference between revisions

Added FreeBASIC
m (→‎{{header|Wren}}: Changed to Wren S/H)
(Added FreeBASIC)
 
(2 intermediate revisions by one other user not shown)
Line 93:
let connect = new System.DirectoryServices.Protocols.LdapConnection(ldapServer)
connect.Bind()</syntaxhighlight>
 
=={{header|FreeBASIC}}==
{{libheader|winldap}}
<syntaxhighlight lang="vbnet">#Include "win\winldap.bi"
 
Dim ldap As LDAP Ptr
Dim hostname As String
Dim port As Integer
Dim username As String
Dim password As String
Dim result As Integer
 
hostname = "ldap.example.com"
port = 389 ' Standard port for LDAP. Use 636 for LDAPS.
username = "cn=username,dc=example,dc=com"
password = "password"
 
' Initialize the LDAP connection
ldap = ldap_init(hostname, port)
If ldap = NULL Then
Print "Error initializing LDAP connection"
Sleep
End 1
End If
 
' Authenticate with the LDAP server
result = ldap_simple_bind_s(ldap, username, password)
If result <> LDAP_SUCCESS Then
Print "Error authenticating with LDAP server: "; ldap_err2string(result)
Sleep
End 1
End If
 
' Here you can perform LDAP operations
'...
 
' We close the connection when finished
ldap_unbind(ldap)</syntaxhighlight>
 
=={{header|Go}}==
Line 485 ⟶ 523:
{{libheader|OpenLDAP}}
As it's not currently possible for Wren-cli to access OpenLDAP directly, we embed a Wren script in a C application to complete this task.
<syntaxhighlight lang="wren">/* active_directory_connectActive_Directory_Connect.wren */
 
foreign class LDAP {
Line 621 ⟶ 659:
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "active_directory_connectActive_Directory_Connect.wren";
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
2,122

edits