You are not logged in.
Pages: 1
How to display any attribute value?
Uinfo: TLdapUser;
WriteLn('ID: '+(UInfo.custom( 'EmployeeID')));
return just nothing (field is not empty)
Offline
Don't put JSON in-between.
LDAPProperties := LDAP.SearchAll([], ObjectFilter(ofUsers, windowsUser), [roCanonicalNameAtRoot, roSortByName, roSddlKnownUuid, roAutoRange, roKnownValuesAsArray]); ... EmployeeID := LDAPProperties.EmployeeID;
@ab, I found your this snippet from other post .
what data types for EmployeeID and LDAPProperties you mean there? I mean var declarations.
Beside datatype question, what is the most proper way to get any single attribute (not listed in ldapuser)?
Last edited by johnnysynop (2025-01-19 12:53:54)
Offline
TLdapClient.SearchAll() returns a variant.
This will be a TDocVariant.
If you want a single attribute, just specify a single so* enum in the TLdapAttributeTypes set.
If you want to specify the attributes as text (e.g. if it is not any TLdapAttributeTypes enum) , you can use TLdapClient.SearchAllDocRaw() or SearchAllRaw().
Offline
thx, I set
var LDAPProperties :variant:= LDAP.SearchAll([], ObjectFilter(ofUsers, windowsUser), [roCanonicalNameAtRoot, roSortByName, roSddlKnownUuid, roAutoRange, roKnownValuesAsArray]);
var EmployeeID:utf8string := LDAPProperties.EmployeeID;
Writeln('EmployeeID: ', EmployeeID);
compiles well but on runtime gives me error:
Could not convert variant of type (Null) into type (String)
but this attribute for that user sure has value I confirmed with windows attribute editor...
Last edited by johnnysynop (Yesterday 07:30:32)
Offline
What actually do you want to do?
The fact that you have the "Could not convert variant of type (Null) into type (String)" error has nothing to do with mORMot, it is your query which returns no result.
You did not define any "EmployeeID" attribute, so of course there is no EmployeeID field value, so LDAPProperties.EmployeeID returns null.
If you want to have the attribute value of one object, and are lost with variants, don't use SearchAll() but just SearchObject().
Then use TLdapResult.Attributes.GetByName().
Something like that:
EmployeeID := LDAP.SearchObject(DN, Filter, ['EmployeeID']).Attributes.GetByName('EmployeeID');
Offline
What actually do you want to do?
I want get single attribute value (employeeId) (not listed in TLdapUser properties) for chosen user in this case "windowsUser" var.
and I thought function Custom(const AttributeName: RawUtf8): RawUtf8; is for that from TLdapUser
or that I can extract it with
var EmployeeID:utf8string := LDAPProperties.EmployeeID;
Last edited by johnnysynop (Yesterday 09:19:14)
Offline
I'm not sure if you understand me
your earlier code
EmployeeID := LDAP.SearchObject(DN, Filter, ['EmployeeID']).Attributes.GetByName('EmployeeID');
gives me AV
Can you please provide sample code, which works for you to get value of EmployeeID attribute for ldap user 'windowsUser'?
I know it sounds trivial for you but I want to make sure that we have consistent result, I mean my AD, Delphi, mormot etc.
Last edited by johnnysynop (Yesterday 15:35:42)
Offline
Pages: 1