• Products
    • View all products
    • Free trials
  • Solutions
    • All Solutions
    • All Integrations
  • Resources
    • All Resources
    • Learning Hub
  • Trials
  • Support
    • Support Home
    • By Product
      • All Products
      • Active Roles
      • Authentication Services
      • Cloud Access Manager
      • Defender
      • Identity Manager
      • Password Manager
      • Safeguard
      • Starling Identity Analytics & Risk Intelligence
      • Starling Two-Factor Authentication
      • TPAM Appliance
    • Contact Support
      • Overview
      • Customer Service
      • Licensing Assistance
      • Renewal Assistance
      • Technical Support
    • Download Software
    • Knowledge Base
    • My Account
      • My Products
      • My Service Requests
      • My Licenses
      • My Groups
      • My Profile
    • Policies & Procedures
    • Professional Services
    • Technical Documentation
    • One Identity University
    • User Forums
    • Video Tutorials
  • Partners
    • Overview
    • Partner Circle Log In
    • Become a Partner
    • Find a Partner
    • Partner Community
  • Communities
    • Home
    • Blogs
      • Blogs A to Z
      • One Identity Community
      • AD Account Lifecycle Management
      • Cloud
      • Identity Governance & Administration
      • Privileged Access Management
      • syslog-ng Community
    • Forums
      • All Product Forums
      • Active Roles
      • Identity Manager
      • Password Manager
      • Safeguard
      • Unix Access Management
    • Social Networks
      • Facebook
      • LinkedIn
      • Twitter
      • YouTube
One Identity Community
One Identity Community
  • Site
  • User
  • Site
  • Search
  • User
Active Roles Community
Active Roles Community
Wiki Safe arrays
  • Forum
  • Ideas
  • Wiki
  • More
  • Cancel
  • New
  • -Active Roles Script Center
    • +Active Roles Script Policy Best Practices
    • Active Roles SDK
    • +C#
    • -JavaScript
      • JavaScript library for Active Roles
      • -JavaScript samples
        • Safe arrays
        • Unlock a user account
    • +PowerShell
    • +VBScript

You are currently reviewing an older revision of this page.

  • History View current version

Safe arrays

Back to JavaScript samples

Some adsi methods return a safe array. Use it by method:

var vbArray = new VBArray(adsiObj.GetEx("cn"))

var values = vbArray.toArray()

So, some adsi methods need a safe array. There is a function of a conversation from javascript array to safe array.

function SafeArray()

{

var dic = new ActiveXObject("Scripting.Dictionary");

var a = arguments;

if (1 == a.length && 'object' == typeof a[0] && Array == a[0].constructor)

a = a[0];

for (var i = 0; i < a.length; i++)

dic.Add(i, aIdea);

return dic.Items()

}

Example of an using:

var userObj = GetObject("LDAP://" + someDN);

userObj.GetInfoEx(SafeArray("department", "title"), 0);

var title = userObj.Get("title");

Advanced

This is a library code extends VBArray object.

// ----------------------------------------------------------------------------

// VBArray

// ----------------------------------------------------------------------------

(function()

{

var dic = new ActiveXObject("Scripting.Dictionary");

//

// Returns safe array from JavaScript array

//

// Example of an using,

// var safeArray1 = VBArray.parse(["A", "B", "C"]) // returns an array has 3 items

// var safeArray2 = VBArray.parse("A", "B", "C") // returns an array has 3 items

VBArray.parse = function()

{

var a = arguments;

if (1 == a.length && "object" == typeof a[0] && Array == a[0].constructor)

a = a[0];

for (var i = 0; i < a.length; i++)

dic.Add(i, aIdea);

var values = dic.Items();

dic.RemoveAll();

return values

}

//

// Returns JavaScript array from safe array.

//

// Example of an using,

// var array1 = VBArray.toArray(safeArray)

VBArray.toArray = function()

{

if (0 == arguments.length || null == arguments[0])

return null

var temp = new VBArray(arguments[0])

return temp.toArray()

}

//

// Returns a length of a VBArray instance

//

// Example of an using,

// var count = VBArray.parse(["A", "B", "C"]).count() // it equals: ["A", "B", "C"].length

VBArray.prototype.count = function()

{

return (1 + this.ubound() - this.lbound())

}

}

Using example:

WScript.Echo("Conversation using");

var safeArray = VBArray.parse("A", "B", "C")

var vbArray = new VBArray(safeArray)

WScript.Echo(" VBArray");

for (var i = 0; i < vbArray.count(); i++)

WScript.Echo(" " + i + ": " + vbArray.getItem(i));

// direct get js array

WScript.Echo(" JS Array");

var jsArray = VBArray.toArray(safeArray);

for (var i = 0; i < jsArray.length; i++)

WScript.Echo(" " + i + ": " + jsArrayIdea);

WScript.Echo("Samples of conversation");

var vb = (new ActiveXObject("Scripting.Dictionary")).Items();

WScript.Echo("[0] " + vb.count());

WScript.Echo("[1] " + VBArray.parse(["A"]).count());

WScript.Echo("[2] " + VBArray.parse("A").count());

WScript.Echo("[3] " + VBArray.parse(["A", "B", "C"]).count());

WScript.Echo("[4] " + VBArray.parse("A", "B", "C").count());

WScript.Echo("[5] " + VBArray.parse([new ActiveXObject("Scripting.Dictionary")]).count());

WScript.Echo("Devil " + VBArray.parse(new ActiveXObject("Scripting.Dictionary")).count());

Back to JavaScript samples

  • Company
    • About Us
    • Buy
    • Careers
    • Contact Us
    • News
  • Resources
    • Blogs
    • Customer Stories
    • Documents
    • Events
    • Videos
  • Support
    • Professional Services
    • Renew Support
    • Technical Support
    • One Identity University
    • Support Service
  • Social Networks
    • Facebook
    • Instagram
    • LinkedIn
    • Twitter
    • YouTube
  • © 2025 One Identity LLC. ALL RIGHTS RESERVED.
  • Legal
  • Terms of Use
  • Privacy
  • Community Feedback & Support
  • Cookie Preference Center