Active Directory/Search for a user: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→{{header|Raku}}: Fix Perl6 -> Raku in comments) |
|||
Line 391: | Line 391: | ||
Surname: Milton |
Surname: Milton |
||
userID: jmilton |
userID: jmilton |
||
</pre> |
|||
=={{header|Phix}}== |
|||
{{trans|C}} |
|||
<lang Phix>include builtins/ldap.e |
|||
constant servers = { |
|||
"ldap.somewhere.com", |
|||
} |
|||
--... |
|||
string name="name", password="passwd" |
|||
--... |
|||
for i=1 to length(servers) do |
|||
atom ld = ldap_init(servers[i]) |
|||
integer res = ldap_simple_bind_s(ld, name, password) |
|||
printf(1,"%s: %d [%s]\n",{servers[i],res,ldap_err_desc(res)}) |
|||
if res=LDAP_SUCCESS then |
|||
{res, atom pMsg} = ldap_search_s(ld, "dc=somewhere,dc=com", LDAP_SCOPE_SUBTREE, |
|||
-- search for all persons whose names start with joe or shmoe |
|||
"(&(objectclass=person)(|(cn=joe*)(cn=shmoe*)))", |
|||
NULL, -- return all attributes |
|||
0) -- want both types and values of attrs |
|||
-- arduously do stuff here to result, with ldap_first_message(), ldap_parse_result(), etc. |
|||
ldap_msgfree(pMsg) -- free messages (embedded NULL check) |
|||
end if |
|||
--... after done with it... |
|||
ldap_unbind(ld) |
|||
end for</lang> |
|||
{{out}} |
|||
Note the code inside res=LDAP_SUCCESS has not been tested beyond compiling succesfully, see also |
|||
the comments in [[Active_Directory/Connect#Phix]] |
|||
<pre> |
|||
ldap.somewhere.com: 81 [LDAP_SERVER_DOWN] |
|||
</pre> |
</pre> |
||