
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2019 12:20 AM
Hi Guys,
I am trying to read some attributes from active directory in ServiceNow using the LDAP query. using below query it will retrieve few attributes only (This is because in the LDAP server attributes we have mentioned around 5 Active directory attributes alone).
var distinguishedName='xyz'
var usrrec ='';
var ldapserver='xyz server;
var gr_LDAP = new GlideRecord('ldap_server_config');
if(gr_LDAP.get('name',ldapserver)){
var iniLdap = new GlideLDAP();
iniLdap.setConfigID(gr_LDAP.getValue('sys_id'));
iniLdap.setup();
var query = "(&(sAMAccountName=" + distinguishedName + "))";
var res = iniLdap.getMatching('', query, true, 10);
while(text=res.next()){
var usrrec = text.toString() + "";
}
}
gs.print(usrrec);
Right now we are getting samAccountName, DN, giveName etc. Now i want to also get the other attributes like phone, email, manager etc. from active directory. Please let me know how to get those attributes using this LDAP query apart from adding the LDAP server attributes.
PS: we don't have/using the orchestration, flow designer etc...
Thanks
Solved! Go to Solution.
- Labels:
-
IntegrationHub

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2019 11:24 PM
This is resolved,.. we have created a new LDAP server and have added the required attributes and then using the script, we are able to fetch the required attributes.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2019 11:24 PM
This is resolved,.. we have created a new LDAP server and have added the required attributes and then using the script, we are able to fetch the required attributes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2019 09:12 AM
Which version is this?
Our Jakarta dies @ var iniLdap = new GlideLDAP();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2019 05:24 PM
I successfully queried an AD/LDAP record, or at least I think I did.
This section gave me errors:
while(text=res.next()){
var usrrec = text.toString() + "";
Retrieving with either "if(res.next())" or "while(res.next())" returned a Glide ldap.ldapresults record marker but I wasn't able to successfully extract specific fields.
I want to retrieve the memberof field from the AD/LDAP record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2022 01:44 AM
Hi Suresh,
very interesting article ..
I have to do a research in ldap but I use a Mid server to connect the ldap, is a way to this in the script?
I receive an error about this..
xxxxxx.zzzz.it:389
LDAP API - LDAPLogger : Communication error: xxxxxx.zzzz.it::389
LDAP API - LDAPLogger : java.net.NoRouteToHostException: No route to host (Host unreachable)
Evaluator: com.glide.script.RhinoEcmaError: Cannot convert null to an object.
thank you for your support
regards
NT