
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2016 09:48 PM
I noticed that if you export these from AD they come out as Hex and when imported into SNOW they seem to be BASE64.
Example:
On a file provided from AD administrator, the guid is as follows: 9e5bab01-07dc-4ba1-a88f-93342f4b0927
Yet that same group when imported into SNOW shows as: AatbntwHoUuoj5M0L0sJJw==
I have found 1 website that accurately converts these from one to the other.
Online GUID Conversion Tool To Convert Hex Base64 Int
Is there a way to convert 9e5bab01-07dc-4ba1-a88f-93342f4b0927 to AatbntwHoUuoj5M0L0sJJw==
Better yet, is there a way to force SNOW to import it in HEX to begin with instead of forcing it to BASE64?
https://youtube.com/watch?v=zYi8KhP9SUk
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2017 04:32 AM
I found the following will prevent the field from being modified from the original guid in ldap.
http://wiki.servicenow.com/index.php?title=Available_System_Properties#gsc.tab=0
http://wiki.servicenow.com/index.php?title=Available_System_Properties#gsc.tab=0
glide.ldap.binary_attributes
Comma-separated list of LDAP attributes that should be converted from binary format to encoded64 strings. If you set this property, only the values listed are converted. The most common attributes are objectSID and objectGUID. These converted values are unique and can be used as the coalesce field on the LDAP import mapping. If this property is blank, ServiceNow tries to map these binary attributes without the conversion and they are not guaranteed to be unique since they are not properly converted to string values. You can set this property for a MID Server to import BLOB data through a MID Server, starting with the Fuji release.
|
https://youtube.com/watch?v=zYi8KhP9SUk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2017 08:42 PM
OK. Posting it here.
This article is about converting Base64 Encoded LDAP ObjectGuid to HexaDecimal format in ServiceNow ITSM platform. If you are looking for ObjectGuid format or conversion tools please disregard this article.
Challenge:
Native MS Tools such as ADSIEdit or FIM display (export) AD objectGuid attribute in hexadecimal format like {F0E0AC71-A46E-437D-95D2-ACC82F57F644}. ServiceNow Imports objectGuid in Base64-encoded format like cazg8G6kfUOV0qzIL1f2RA==. You want to convert Base64-encoded objectGuid to hexadecimal format.
Solution:
Here is the script include that will help you:
var guidUtils = Class.create();
guidUtils.prototype = {
initialize: function() {
},
base64ToHex: function (str){
var decoded = GlideStringUtil.base64DecodeAsBytes(str);
var n = decoded.length;
if (n<16){
return '';
}
var retVal = '';
retVal = retVal + this.prefixZeros(decoded[3] & 0xFF).toUpperCase();
retVal = retVal + this.prefixZeros(decoded[2] & 0xFF).toUpperCase();
retVal = retVal + this.prefixZeros(decoded[1] & 0xFF).toUpperCase();
retVal = retVal + this.prefixZeros(decoded[0] & 0xFF).toUpperCase();
retVal = retVal +'-';
retVal = retVal + this.prefixZeros(decoded[5] & 0xFF).toUpperCase();
retVal = retVal + this.prefixZeros(decoded[4] & 0xFF).toUpperCase();
retVal = retVal +'-';
retVal = retVal + this.prefixZeros(decoded[7] & 0xFF).toUpperCase();
retVal = retVal + this.prefixZeros(decoded[6] & 0xFF).toUpperCase();
retVal = retVal +'-';
retVal = retVal + this.prefixZeros(decoded[8] & 0xFF).toUpperCase();
retVal = retVal + this.prefixZeros(decoded[9] & 0xFF).toUpperCase();
retVal = retVal +'-';
retVal = retVal + this.prefixZeros(decoded[10] & 0xFF).toUpperCase();
retVal = retVal + this.prefixZeros(decoded[11] & 0xFF).toUpperCase();
retVal = retVal + this.prefixZeros(decoded[12] & 0xFF).toUpperCase();
retVal = retVal + this.prefixZeros(decoded[13] & 0xFF).toUpperCase();
retVal = retVal + this.prefixZeros(decoded[14] & 0xFF).toUpperCase();
retVal = retVal + this.prefixZeros(decoded[15] & 0xFF).toUpperCase();
retVal = '{'+retVal + '}';
return retVal;
},
prefixZeros: function (value) {
if (value <= 0xF) {
return '0'+value.toString(16);
} else {
return value.toString(16);
}
},
type: 'guidUtils'
};
Usage Example:
var h = new guidUtils();
gs.log(h.base64ToHex('cazg8G6kfUOV0qzIL1f2RA=='));
Output:
[0:00:00.001] Script completed in scope global: script
*** Script: {F0E0AC71-A46E-437D-95D2-ACC82F57F644}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2017 02:22 AM
I have issues with visiting the link above so I solved It like this.
In transform map I've used source script to target a custom field (u_external_id).
answer = (function transformEntry(source) {
function toHex(d) {
return ("0" + Number(d).toString(16)).slice(-2).toUpperCase();
}
function a2b(a) {
var b, c, d, e = {},
f = 0,
g = 0,
h = "",
i = String.fromCharCode,
j = a.length;
for (b = 0; 64 > b; b++) e["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(b)] = b;
for (c = 0; j > c; c++)
for (b = e[a.charAt(c)], f = (f << 6) + b, g += 6; g >= 8;)((d = 255 & f >>> (g -= 8)) || j - 2 > c) && (h += i(d));
return h;
}
function arrayToGuid(arr) {
// Why reverse? Something about little and big endian.
return arr.slice(0, 4).reverse().join('').toLowerCase() + '-' + arr.slice(4, 6).reverse().join('').toLowerCase() + '-' + arr.slice(6, 8).reverse().join('').toLowerCase() + '-' + arr.slice(8, 10).join('').toLowerCase() + '-' + arr.slice(10, 16).join('').toLowerCase();
}
function base64StringToGuid(base64string) {
var charArray = GlideStringUtil.base64Decode(base64string).split('').map(function(el) {
return el.charCodeAt(0);
}).map(function(el) {
return toHex(el);
});
return arrayToGuid(charArray);
}
return base64StringToGuid(source.u_objectguid); // return the value to be put into the target field
})(source);
You could try this in browser-console before implementing on your instance.
function toHex(d) {
return ("0" + Number(d).toString(16)).slice(-2).toUpperCase();
}
function arrayToGuid(arr) {
// Why reverse? Something about little and big endian.
return arr.slice(0, 4).reverse().join('').toLowerCase() + '-' + arr.slice(4, 6).reverse().join('').toLowerCase() + '-' + arr.slice(6, 8).reverse().join('').toLowerCase() + '-' + arr.slice(8, 10).join('').toLowerCase() + '-' + arr.slice(10, 16).join('').toLowerCase();
}
function base64StringToGuid(base64string) {
var charArray = atob(base64string).split('').map(function(el) {
return el.charCodeAt(0);
}).map(function(el) {
return toHex(el);
});
return arrayToGuid(charArray);
}
console.log(base64StringToGuid("AatbntwHoUuoj5M0L0sJJw==")); // return the value to be put into the target field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2018 05:50 AM
Hi John,
I know this is year old post, but i urgently need solution for this and for which i could not find solution anywhere, so just want to consult with you get some idea, how to change Hexvalue to Base64 in Ldap to service now.
AD objectGUID value : f52afee8-33b1-4df5-a497-89bdf5b65caf (Hex value)
After transform map in LDAP shows: LY/xoAyrS0WLjcCFUpVwBw== (Base64)
I tried with
var base64string = GlideStringUtil.base64Encode("f52afee8-33b1-4df5-a497-89bdf5b65caf");
gs.log(base64string);
Orig = GlideStringUtil.base64Decode(base64string);
gs.log(orig);
But not getting the desired result, which is base64 value. Returning same Hex value. So please help me how you have converted them to Base64 value
*** Script: ZjUyYWZlZTgtMzNiMS00ZGY1LWE0OTctODliZGY1YjY1Y2Fm
*** Script: f52afee8-33b1-4df5-a497-89bdf5b65caf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2018 12:08 AM
Hello,
Did you, by any chance found the solution for this ? I'm stuck with the same requirement, I can't translate properly the hex to b64 and the other way around.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2019 06:39 AM
I have to precise the issue was only on SID not GUID but we applied a workaround on the source of the import with a powershell script.