LDAP date field issue

Khasim Shaik1
Kilo Expert

Hi Team,

I am trying to update employee end in user table from AD (accountExpires) .  AD date value coming like "132590304000000000" this format So, I have converted this to date format using below script . 

Issue is updating one day ahead for few users 

Ex: user has employee end date of 2021-02-28 where the AD account is set to expire on 2021-02-27.

 

function getLocalTimeZoneDateTime(dateTimeUTC) {

var gdt = new GlideDateTime(dateTimeUTC);
gs.log("Date " + gdt);
return gdt.getDisplayValueInternal();
}
var dtUtil = new DateTimeUtils();
if (source.u_accountexpires === undefined) {
// set a blank value if the source is 'undefined'
target.setValue("u_employee_end_date",'');
} else if (source.u_accountexpires != 0) {
gs.log("source date" + source.u_userprincipalname + " :" + source.u_accountexpires);
// convert the date from int8 format to GlideDateTime in UTC
var expiresUTC = dtUtil.int8ToGlideDateTime(source.u_accountexpires);
// convert the GlideDateTime in UTC to Local TimeZone
var expiresLocal = getLocalTimeZoneDateTime(expiresUTC);
gs.log("Target date " +source.u_userprincipalname + " : " + expiresLocal);
//log.info("ExpiresLocal: " + expiresLocal);
// Set the value to the Local Time Zone value
//target.setValue("u_employee_end_date", expiresLocal);
} else {
// set a blank value if the source is anything else.
target.setValue("u_employee_end_date", '');
}

 

Thanks,

Khasim

1 ACCEPTED SOLUTION

Khasim Shaik1
Kilo Expert

I have fixed this issue with below article

The article also talks about the calculation issues with this being a day off

 

http://www.rlmueller.net/AccountExpires.htm

 

Thanks,

Khasim

View solution in original post

9 REPLIES 9

Khasim Shaik1
Kilo Expert

I have fixed this issue with below article

The article also talks about the calculation issues with this being a day off

 

http://www.rlmueller.net/AccountExpires.htm

 

Thanks,

Khasim

Hi Khasim,

Could you please let me know how did you solve this issue through scripting? Even I am looking to convert this 18digit value to date and import into User table field.

RaiPalash
Giga Contributor

Hey, I'm learning SN and I'm a rookie 

can u please help me in understanding LDAP v/s SSO ?

 

@RaiPalash LDAP is used for creating user records and groups in Servicenow. 

Administrators integrate with a Lightweight Directory Access Protocol LDAP directory to streamline the user login process and to automate administrative tasks such as creating users and assigning them roles. An LDAP integration allows the system to use your existing LDAP server as the primary source of user data.

 

LDAP authenticationUse LDAP authentication to access using LDAP credentials.

When a user enters network credentials in the login page:
  1. The instance passes the credentials to an LDAP server to find the instance.
  2. With RDNs, it validates the user's DN string. It validates only if at least one of the LDAP OU configurations  has an RDN configured.
  3. The LDAP server responds with an authorized or unauthorized message that the system uses to determine whether access should be granted.

By authenticating against your LDAP server, users access the platform with the same credentials that they use for other internal resources on your network domain. Also, you can reuse any existing password and security policies that are already in place. For example, the LDAP server may already have account lockout and password expiration policies.

 

Refer : https://docs.servicenow.com/en-US/bundle/utah-platform-security/page/integrate/ldap/concept/c_LDAPIn... 

 

SSO: 

External SSO allows organizations to use several SSO identity providers (IdPs) to manage authentication as well as retain local database (basic) authentication. Example : OKTA. 

Refer :https://docs.servicenow.com/bundle/utah-platform-security/page/integrate/single-sign-on/concept/c_Mu...

 

Please mark helpful and accept solution if you have got the clarity.

 

 

Thanks for the help