diff --git a/process/ActiveDirectoryXml_lib/process.js b/process/ActiveDirectoryXml_lib/process.js index bec525089158d0cfca9a739a4173a0d9676adc2a..ce901db274073dcdca6a56f39c7d0efb61ccd439 100644 --- a/process/ActiveDirectoryXml_lib/process.js +++ b/process/ActiveDirectoryXml_lib/process.js @@ -1,64 +1,54 @@ import("Util_lib"); import("system.plugin"); -//TODO: translate all comments to english +//TODO: translate all comments to english (currently only partially done) //TODO: name parameters correctly (with 'p' prefix) //TODO: set methods on the prototype, not for every instance (also check if the inheritance is correct) -/* - * LDAPI Objekt stellt die Methoden zum Ausführen LDAP Actionen zur Verfügung. - * - * -*/ +/** + * LDAPI provides methods for the execution of LDAP actions. + */ function LDAPI () { - //die Actionbeschreibung als XML String. + //the action description as XML string this.actionParameter = null; - /* - * Setzt die Actionsbeschreibung (Parameter) - * - * @param {String} actionAsXMLString req pActionAsXMLString XML String mit ActionBeschreibung - * - * @return {void} - */ - this.setInputParameter = function (actionAsXMLString) + /** + * Sets the action description + * + * @param {String} pActionAsXMLString XML String with action description + */ + this.setInputParameter = function (pActionAsXMLString) { - this.actionParameter = actionAsXMLString; + this.actionParameter = pActionAsXMLString; } - /* - * - * Führt eine Action auf ActiveDirectory aus - * - * @throws Falls keine LDAP Action definiert - * - * @param {String/XML} pParameter - die Action Beschreibung als XML String bzw. XML Object. - * - * @return {String[]} - Element [0] ist Ergebnis des Aufrufes als XML String - * + /** + * Executes an action on the active directory + * + * @param {String/XML} pParameter action descripton as XML string or XML object + * @return {String[]} element [0] is the result as XML string + * @throws If no LDAP action is defined */ this.run = function (pParameter) { - //falls pParameter nicht defeniert ist, verwende this.actionParameter + //if pParameter is not defined, use this.actionParameter if (pParameter !== undefined && pParameter !== null) { - //pParameter ist ein String - if (pParameter instanceof String) + if (Utils.isString(pParameter)) this.actionParameter = pParameter; - //pParameter ein XML Objekt if (pParameter instanceof XML) this.actionParameter = pParameter.toXMLString(); else - //sonstige Objekt der toStringMethode überladen hat und liefert mit toString Methode ein XML String - //jede "xxxxAction" Objekt hat eine toString Methode überschrieben. - this.actionParameter=pParameter.toString(); + //other objects may have the toString method overridden to deliver an XML string if it is called + //every "xxxxAction" object has an overridden toString method + this.actionParameter = pParameter.toString(); } if (this.actionParameter == null) - throw ("Keine LDAP Action definiert!"); + throw ("No LDAP action defined!"); - //action ausführen + //execute action this.actionParameter = new XML(this.actionParameter.toString().replace(new RegExp('<', 'g'), '<').replace(new RegExp('>', 'g'), '>')); @@ -69,133 +59,121 @@ function LDAPI () } } -/* -* DNEntry Objekt repräsentiert ein ActivDirectory Eintrag mit DN und Attributen. -* -* @param {XML} dnEntry req als XML Object -* -* @property String dn -dn des Eintrages -* @property LDAPAttribute[] Attribute - die Attribute des Eintrages. -* @property String asXMLString - der Eintrag als XML String. -*/ -function DNEntry (dnEntry) +/** + * DNEntry represents an activeDirectory entry with DN and attributes. + * + * @param {XML} pDnEntry as XML Object + * @property String dn dn of the entry + * @property LDAPAttribute[] Attribute attributes of the entry + * @property String asXMLString entry as XML string + */ +function DNEntry (pDnEntry) { - this.dn = "";//dn des Eintrages - this.Attribute = null;//Attribute, defaultmässig null. - this.asXMLString = "";//AD Eintrag als XML String + this.dn = ""; //dn of the entry + this.Attribute = null; //Attribute, default null. + this.asXMLString = ""; //AD entry as XML string - /* - * Setzt den aktuellen DN - * - * @param {String} dn req Neuer DN des Eintrages - * - * return {void} - */ - this.setDN = function (dn) + /** + * Sets the DN + * + * @param {String} pDn new DN of the entry + */ + this.setDN = function (pDn) { - if(dn !== undefined && dn !== null) - this.dn = dn; + if (pDn !== undefined && pDn !== null) + this.dn = pDn; } - /* - * Liefert den DN des Eintrages zurück - * - * return {String} DN des Eintrags - */ + /** + * Returns the DN of the entry + * + * return {String} DN of the entry + */ this.getDN = function () { return this.dn.toString(); } - /* - * Liefert die Attribute des Eintrages zurück + /** + * Returns the attribute(s) of the entry * - * @return {LDAPAttribute[]} die Attribute des Eintrages + * @return {LDAPAttribute[]} attribute */ - this.getAttribute = function (name) + this.getAttribute = function (pName) { - if (name === undefined || name === null) + if (pName === undefined || pName === null) return this.Attribute; else - return this.getAttributeByName(name); + return this.getAttributeByName(pName); } - /* - * Liefert die Attribute des Eintrages das bestimmten Namen hat zurück - * - * @param {String} name req Der Name - * + /** + * Returns the attribute with the specified name * - * @return {LDAPAttribute} Die Attribute des Eintrages namens name + * @param {String} pName name of the attribute + * @return {LDAPAttribute} the desired attribute */ - this.getAttributeByName=function(name) + this.getAttributeByName = function (pName) { if (this.Attribute == null) return this.Attribute; for (let i = 0; i < this.Attribute.length; i++) { - if (this.Attribute[i].getName() == name) + if (this.Attribute[i].getName() == pName) return this.Attribute[i]; } return null; } - /* - * Liefert die Attribute des Eintrages das bestimmten Namen hat zurück + /** + * Returns the value of the attribute with the specified name * - * @param {String} name req -der Name - * - * @return {LDAPAttribute} Die Attribute des Eintrages namens name + * @param {String} pName name of the attribute + * @return {String[]} value of the attribute */ - this.getAttributeValues=function(name) + this.getAttributeValues = function (pName) { - if(this.Attribute == null) + if (this.Attribute == null) return this.Attribute; for (let i = 0; i < this.Attribute.length; i++) { - if(this.Attribute[i].getName() == name) + if(this.Attribute[i].getName() == pName) return this.Attribute[i].getValues(); } return null; } - /* - * Fügt ein oder mehreren Attribute dem Entrag hinzu. - * Achtung! Es wird nicht überprüft, ob ein Attribut bzw. Wert eines Attributes bereits vorhanden ist! - * Sondern es wird einfach hinzufügt. + /** + * Adds one or several attributes to the entry. + * Be careful, this does not check if an attribute is already present! * - * @param {XML/LDAPAttribute[]/LDAPAttribute} attribute req Ein oder mehrere LDAPAttribute oder ein Attribut als XML Object zum Hinzufügen. + * @param {XML/LDAPAttribute[]/LDAPAttribute} pAttribute LDAPAttribute/-array or XML object that should be added */ - this.addAttribute = function (attribute) + this.addAttribute = function (pAttribute) { - if (attribute === undefined || attribute === null) + if (pAttribute === undefined || pAttribute === null) return; if (this.Attribute == null) - this.Attribute = new Array(); + this.Attribute = []; - //falls attribute ein LDAPAttribute[] - if (attribute instanceof Array) - { - this.Attribute.concat(attribute); - } - //falls attribute ein XML Objekt ist - if (attribute instanceof XML) - { - this.Attribute.push(new LDAPAttribute(attribute)) - } - else - //attribute ist ein LDAPAttribute - this.Attribute.push(attribute); + if (Array.isArray(pAttribute)) + this.Attribute = this.Attribute.concat(pAttribute); + + if (pAttribute instanceof XML) + this.Attribute.push(new LDAPAttribute(pAttribute)); + else //attribute is LDAPAttribute + + this.Attribute.push(pAttribute); } - /* - * Überschreibt toString(). liefert den Eintrag als XML String zurück. + /** + * Custom toString(), delivers the entry as XML string * - * @return {String} Der Eintrag als XML String. + * @return {String} entry as XML string */ this.toString = function () { @@ -203,40 +181,37 @@ function DNEntry (dnEntry) // return this.asXMLString; } - //dnEntry as XML String abspeichern - this.asXMLString = dnEntry.toXMLString(); + this.asXMLString = pDnEntry.toXMLString(); - //dn Setzen - this.setDN(dnEntry.absolutDN); + this.setDN(pDnEntry.absolutDN); - //die Attribute durchlaufen - for each(attr in dnEntry.attributes.attribute) + for each (let attr in pDnEntry.attributes.attribute) { this.addAttribute(attr); } } -/* - * Dierser Object representiert den Ergebnis eines LDAPI Aufrufes und stellt Methoden zur Abfrage des Status, Fehlermeldung, Attribute - * und AD Einträge, die von Aufruf der Schnittstelle zurückgeliefert werden, zur Verfügung. +/** + * This objects represents the result of a LDAPI call and provides methods for retrieving the status, error messages, attributes + * and AD entries of the result which the api returned. * - * @param {String} resultXML req -XML String + * @param {String} pResultXML XML string with the result * - * @property DNEntry[] entrys - AD Einträge - * @property LDAPAttribute[] attribute - die Attribute - * @property String message - die Fehlermeldung (bei NullPointerException kann auch leer sein). - * @property Boolean status - der Staus des LDAPI Aufrufes true/false - * @property String resultAsXMLString - der ergebnis als XML String + * @property {DNEntry[]} entrys AD entries + * @property {LDAPAttribute[]} attribute attributes + * @property {String} message error message (can be empty for a NullPointerException) + * @property {Boolean} status status of the LDAPI call, true/false + * @property {String} resultAsXMLString result as XML string */ -function LDAPIResult (resultXML) +function LDAPIResult (pResultXML) { - this.entrys = new Array(); // AD Einträge - this.attribute = new Array(); - this.message = ""; //die Fehlermeldung (bei NullPointerException kann auch leer sein). - this.status = undefined; //der Staus des LDAPI Aufrufes true/false - this.resultAsXMLString = ""; //der ergebnis als XML String + this.entrys = []; + this.attribute = []; + this.message = ""; + this.status = undefined; + this.resultAsXMLString = ""; - /* + /** * Liefert die AD Einträge aus dem Ergebniss (z.B bei der Suche) zurück. * * @return {DNEntry[]} - AD Einträge @@ -246,7 +221,7 @@ function LDAPIResult (resultXML) return this.entrys; } - /* + /** * Liefert die Attribute aus dem Ergebniss (z.B beim Lesen) zurück. * * @return {LDAPAttribute[]} - die Attribute @@ -256,7 +231,7 @@ function LDAPIResult (resultXML) return this.attribute; } - /* + /** * Liefert den Status des Aufrufes zurück true/false. * * @return {boolean} true=alles ok/false=ein Fehler. @@ -266,7 +241,7 @@ function LDAPIResult (resultXML) return this.status; } - /* + /** * Liefert die Fehlermeldung zurück. * * @return {String} die Fehlermeldung. @@ -276,7 +251,7 @@ function LDAPIResult (resultXML) return this.message; } - /* + /** * Liefert der Ergebniss als ein XML String zurück. * * @return {String} - der Ergebniss als ein XML String. @@ -286,7 +261,7 @@ function LDAPIResult (resultXML) return this.resultAsXMLString; } - /* + /** * Liefert der Ergebniss als ein String zurück. * * @return {String} - der Ergebniss als ein String. @@ -306,33 +281,33 @@ function LDAPIResult (resultXML) } //prüfe, ob Result ein String ist. Falls nicht gehe von einem XML Objekt aus. - if (typeof(resultXML) == 'string') + if (Utils.isString(pResultXML)) { - this.resultAsXMLString = resultXML; - resultXML = new XML(resultXML); + this.resultAsXMLString = pResultXML; + pResultXML = new XML(pResultXML); } else { - this.resultAsXMLString = resultXML.toXMLString(); + this.resultAsXMLString = pResultXML.toXMLString(); } - this.message = resultXML.message; - this.status = resultXML.status == "true"; + this.message = pResultXML.message; + this.status = pResultXML.status == "true"; //die Entrys Speichern - for each (entry in resultXML.entrys.entry) + for each (entry in pResultXML.entrys.entry) { this.entrys.push(new DNEntry(entry)); } //die Attribute speichern - for each (attribte in resultXML.attributes.attribute) + for each (attribte in pResultXML.attributes.attribute) { this.attribute.push(new LDAPAttribute(attribte)); } } -/* +/** * Konstruktorfunktion, noch keine Beschreibung vorhanden * * @param {String} user req -User DN. @@ -351,7 +326,7 @@ function LoginData (user, pwd, url, sa, re) <referral>ignore</referral> </loginData>); - /* + /** * Setzt die Verweisung. Mögliche Werte sind z.B "follow", * "ignore", "throw" * @@ -365,7 +340,7 @@ function LoginData (user, pwd, url, sa, re) this.xmlLogin.referral=re; } - /* + /** * Gibt die Verweisung zurück. * * @return {String} den Verweisung. @@ -375,7 +350,7 @@ function LoginData (user, pwd, url, sa, re) return this.xmlLogin.referral.toString(); } - /* + /** * Setzt den Verschlüsselungstype. Mögliche Werte sind z.B "DIGEST-MD5","simple" etc. . * * @param {String} sa req -der Verschlüsselungstype. @@ -388,7 +363,7 @@ function LoginData (user, pwd, url, sa, re) this.xmlLogin.securityAuthentication=sa; } - /* + /** * Gibt den Verschlüsselungstype zurück. * * @return {String} den Verschlüsselungstype. @@ -398,7 +373,7 @@ function LoginData (user, pwd, url, sa, re) return this.xmlLogin.securityAuthentication.toString(); } - /* + /** * Setzt den User Name. * * @param {String} user req der User Name. @@ -409,7 +384,7 @@ function LoginData (user, pwd, url, sa, re) this.xmlLogin.userDN = user; } - /* + /** * Gibt den User Name zurück. Falls kein User gesetzt leeres String. * * @return {String} der User Name oder leer String. @@ -419,7 +394,7 @@ function LoginData (user, pwd, url, sa, re) return this.xmlLogin.userDN.toString(); } - /* + /** * Setzt des Passwort. * * @param {String} pwd req Das Passwort. @@ -430,7 +405,7 @@ function LoginData (user, pwd, url, sa, re) this.xmlLogin.passwort = pwd; } - /* + /** * Gibt das Passwort zurück. Falls kein Passwort gesetzt leeres String. * * @return {String} Das Passwort oder leer String. @@ -440,7 +415,7 @@ function LoginData (user, pwd, url, sa, re) return this.xmlLogin.passwort.toString(); } - /* + /** * Setzt die LDAP Servet URL und Port z.B. ("ldap://127.0.0.1:10389/";). * * @param {String} url req Die LDAP Servet URL. @@ -451,7 +426,7 @@ function LoginData (user, pwd, url, sa, re) this.xmlLogin.URL = url; } - /* + /** * Gibt die LDAP Server URL zurück.Falls keine LDAP Server URL gesetzt leeres String. * * @return {String} Die LDAP Server URL oder leer String. @@ -461,7 +436,7 @@ function LoginData (user, pwd, url, sa, re) return this.xmlLogin.URL; } - /* + /** * Gibt die Login Daten als String Message zurück. Geignet z.B. für die formatierte Ausgabe auf die Konsole. * * @return {String} die Login Daten als formatierter String. @@ -478,7 +453,7 @@ function LoginData (user, pwd, url, sa, re) this.setReferral(re); } -/* +/** * Dieser Objekt representiert ein AD Attribut und stellt die Methoden zur Abfrage des Namens und Werten eienes Attributes zur Verfügung. * * @param {String/XML} arg0 req - entweder der Name des Attributes als String oder XML String(komplettes Atribut). @@ -490,7 +465,7 @@ function LDAPAttribute (arg0, pValues) this.name = "";//name this.values = null;//array mit Werten - /* + /** * Gibt das Attribute als XML Zurück * * @return {String} - das Attribute als XML String. @@ -513,64 +488,59 @@ function LDAPAttribute (arg0, pValues) return attrAsXML.toXMLString(); } - /* + /** * Fügt einen oder mehreren Attributenwert/e dem Objekt hinzu * * @param {String/String[]} pValues req -ein oder mehrer Attributenwerte zum Hinzufügen - * - * @return {void} - */ + */ this.addValue = function (pValues) { - if (pValues === undefined || pValues === null) return; if (this.values == null) - this.values = new Array(); - if (typeof(pValues) == "object") + this.values = []; + if (Array.isArray(pValues)) this.values = this.values.concat(pValues); else this.values.push(pValues); } - /* + /** * Liefert einen oder mehreren Attributenwert/e zurück.Hat die Attribute keine Werte dann null. * * @return {String[]} pValues req -ein oder mehrer Attributenwerte. Hatt die Attribute keine Werte dann null. - */ + */ this.getValues = function () { return this.values; } - /* + /** * Setzt der Name des Attribuutes. - * - * @return {void} - */ - this.setName = function (name) + */ + this.setName = function (pName) { - if (name !== undefined && name !== null) - this.name = name; + if (pName !== undefined && pName !== null) + this.name = pName; } - /* + /** * Liefert der Name des Attributes. * * @return {String} der Name des Attributes. - */ + */ this.getName = function() { return this.name.toString(); } - /* + /** * Überschreibt toString() Methode. Gibt das Attribute als XML String zurück. * * @return {String} Attirute als XML String - */ + */ this.toString = function() { return this.toXMLString(); @@ -598,7 +568,7 @@ function LDAPAttribute (arg0, pValues) } } -/* +/** * Basis Action. Beinhaltet Eigenschaften und Methoden die alle Abgeleitet Actions auch haben sollen. * * @param {String} type req -der Actiontype.Zulläsig sind:"read","remove","add","replace","search", "create" . @@ -609,8 +579,7 @@ function LDAPAttribute (arg0, pValues) * Meistens steht null für alle, leeres Array für keine Attribute. * * @property String xmlAction - die XML Action als XML String - * -*/ + */ function BaseAction (type, login, dn, attribute) { @@ -619,17 +588,18 @@ function BaseAction (type, login, dn, attribute) }></{ type }>); - /* + + /** * Gibt die LoginDaten zurück. * * @return {LoginDate} -die Login Daten - */ + */ this.getLogin = function () { return this.xmlAction.loginData; } - /* + /** * Setzt die LoginDaten. * * @param {LoginDate} pLogin req -die Login Daten @@ -640,7 +610,7 @@ function BaseAction (type, login, dn, attribute) this.xmlAction.appendChild(pLogin); } - /* + /** * Gibt DN zurück. * * @return {String} DN @@ -650,72 +620,70 @@ function BaseAction (type, login, dn, attribute) return this.xmlAction.dn; } - /* + /** * Setzt DN. * - * @param {String} dn -DN zulässig sind (add,read,replace,remove,create) - */ - this.setDN = function (dn) + * @param {String} pDn -DN zulässig sind (add,read,replace,remove,create) + */ + this.setDN = function (pDn) { - if(dn !== null && dn !== undefined) - this.xmlAction.dn = dn; + if (pDn !== null && pDn !== undefined) + this.xmlAction.dn = pDn; } - /* + /** * Gibt die Aktionstype zurück * * @return {String} die Actionstype - */ + */ this.getActionType = function() { return this.xmlAction.Name(); } - /* + /** * Fügt ein oder mehreren Attribute der Action hinzu. * Achtung! Es wird nicht überprüft, ob ein Attribut bzw. Wert eines Attributes bereits vorhanden ist! * Sondern es wird einfach hinzufügt. * - * @param {LDAPIAttribut\LDAPIAttribut[]} attr req ein oder mehrere Attributennamen bzw. ein oder mehrere Attribute als XML. - */ - this.addAttribute = function (attr) + * @param {LDAPIAttribut\LDAPIAttribut[]} pAttribute req ein oder mehrere Attributennamen bzw. ein oder mehrere Attribute als XML. + */ + this.addAttribute = function (pAttribute) { - if(attr === null || attr === undefined) + if(pAttribute === null || pAttribute === undefined) return; //ist der "attributes Knoten bereits existiert?" if (this.xmlAction.attributes.length() <= 0) this.xmlAction.appendChild(<attributes/>); - if (attr instanceof Array) + if (Array.isArray(pAttribute)) { - for (let i = 0; i < attr.length; i++) - this.addSingleAttribute(attr[i]); + for (let i = 0; i < pAttribute.length; i++) + this.addSingleAttribute(pAttribute[i]); } else { - this.addSingleAttribute(attr); + this.addSingleAttribute(pAttribute); } } - /* + /** * Diese Methode prüft ob ein Attribut bereits existiert ist. Falls ein existiert denn wird der Wert dem Attribut hinzufügt. * Falls nicht existiert wird das Attributt der Attributtenliste kommplett hinzufügt. * - * @param {XML} attr req - ein Attribut - * - * @return {void} - */ - this.addSingleAttribute = function (attr) + * @param {XML} pAttribute req - ein Attribut + */ + this.addSingleAttribute = function (pAttribute) { - var name = attr.getName(); + var name = pAttribute.getName(); if (this.xmlAction.attributes.attribute.(@name==name).length()==0) { - this.xmlAction.attributes.appendChild(new XML(attr.toXMLString())); + this.xmlAction.attributes.appendChild(new XML(pAttribute.toXMLString())); } else { - var valuesArray = attr.getValues(); + var valuesArray = pAttribute.getValues(); if (valuesArray !== undefined && valuesArray !== null) { for (let i = 0; i < valuesArray.length; i++) @@ -727,15 +695,13 @@ function BaseAction (type, login, dn, attribute) } } - /* + /** * Diese Methode prüft ob ein Attributenwert bereits existiert ist. Falls ein existiert denn wird der Wert ignoriert. * Falls nicht existiert wird der Wert der Werteliste hinzufügt. * * @param {String} pName req - der Attributenname * @param {String} pValue req - der Attributenwert - * - * @return {void} - */ + */ this.addSingleAttributeValue = function (pName, pValue) { for each (var val in this.xmlAction.attributes.attribute.(@name==pName).value) @@ -749,21 +715,21 @@ function BaseAction (type, login, dn, attribute) } - /* - * Gibt die Attribute auf die Action ausgeführt soll, als XML String zurück - * - * @return String - Attribute auf die Action ausgeführt soll, als XML String - */ + /** + * Gibt die Attribute auf die Action ausgeführt soll, als XML String zurück + * + * @return String - Attribute auf die Action ausgeführt soll, als XML String + */ this.getXMLAttribute = function () { return this.xmlAction.attributes; } - /* - * Überschreibt Standard-toString-Methode - * - * @return {String} xmlAction - */ + /** + * Überschreibt Standard-toString-Methode + * + * @return {String} xmlAction + */ this.toString = function () { return this.xmlAction; @@ -776,7 +742,7 @@ function BaseAction (type, login, dn, attribute) this.addAttribute(attribute); } -/* +/** * Action um bestimmte oder alle Attribute enes AD Eintrages auslesen. * * @param {LoginData} login req -Logindaten @@ -784,8 +750,7 @@ function BaseAction (type, login, dn, attribute) * @param {LDAPIAttribute[]} attribute req - [Attribute auf die Action angewendet soll. * Achtung! null und leeres Araay sind zulüssig und spielen auch bei dieser Action eine wichtige Rolle! * null für alle, leeres Array für keine Attribute auslesen.] - * -*/ + */ function ReadAction (login, dn, attribute) { this.inheritFrom = BaseAction; @@ -793,14 +758,13 @@ function ReadAction (login, dn, attribute) } -/* +/** * Action um Attribute enem AD Eintrages hinzufügen. * * @param {LoginData} login req -Logindaten * @param {String} dn req -der DN des AD Eintrages. * @param {LDAPIAttribute[]} attribute req - [Attribute auf die Action angewendet soll. Darf nicht null sein!] - * -*/ + */ function AddAction (login, dn, attribute) { this.inheritFrom = BaseAction; @@ -808,15 +772,14 @@ function AddAction (login, dn, attribute) } -/* +/** * Action um Attribute eines AD Eintrages zu ersetzen. * * @param {LoginData} login req -Logindaten * @param {String} dn req -der DN des AD Eintrages. * @param {LDAPIAttribute[]} attribute req - Attribute auf die Action angewendet soll. Darf nicht null sein!. * Es ist nicht möglich ein Attribut namens xyz mit dem Wert abs durch anderen Wert zu ersetzen. Ein Atributt wird komplett ersetzt! - * -*/ + */ function ReplaceAction (login, dn, attribute) { this.inheritFrom = BaseAction; @@ -824,7 +787,7 @@ function ReplaceAction (login, dn, attribute) } -/* +/** * Action um die Eintrage nach bestimten Filter kriterien zu suchen. Dabei ist es möglich festzulegen ob alle,bestimmte * oder keine Attribute der gefunden Einträge zurück geliefert werden sollen. * @@ -838,7 +801,7 @@ function ReplaceAction (login, dn, attribute) * @property {String} filter - [ein Suchkriterium(AD Syntax z.B (&(objectClass=person)(telephoneNumber=*)) - alle Personnen die ein Attribut telephoneNumber haben)] * @property {Integer} limits - max. Anzahl Einträge die zurück geliefert werden. * -*/ + */ function SearchAction (login, dn, attribute) { @@ -850,72 +813,63 @@ function SearchAction (login, dn, attribute) this.paging = false; - /* + /** * Setze die Paging. Wert "true" paging aktiviert "false" deaktiviert. * - * @param {String} isPaging req -der pagingwert. - * - * @return {void} - */ - this.setPaging = function (isPaging) + * @param {String} pIsPaging req -der pagingwert. + */ + this.setPaging = function (pIsPaging) { - if (isPaging !== null && isPaging !== undefined) - this.xmlAction.paging = isPaging; + if (pIsPaging !== null && pIsPaging !== undefined) + this.xmlAction.paging = pIsPaging; } - /* + + /** * Setze den Suchbereich. Zulläsig sind "base","one-level","subtree" * - * @param {String} scope req -der Suchbereich. - * - * @return {void} - */ - this.setScope = function (scope) + * @param {String} pScope req -der Suchbereich. + */ + this.setScope = function (pScope) { - if (scope != null && scope !== undefined) - this.xmlAction.scope = scope; + if (pScope !== null && pScope !== undefined) + this.xmlAction.scope = pScope; } - /* + /** * Setze max. Anzahl Einträge die zurück geliefert werden. Defaulmässig 1000. * * @param {Integer} pPaging req - max. Anzahl Einträge die zurück geliefert werden. - * - * @return {void} - */ + */ this.setPaging = function (pPaging) { if (pPaging !== null && pPaging !== undefined) this.xmlAction.paging = pPaging; } - /* + /** * Setze max. Anzahl Einträge die zurück geliefert werden. Defaulmässig 1000. * * @param {Integer} pLimits req - max. Anzahl Einträge die zurück geliefert werden. - * - * @return {void} - */ + */ this.setLimits = function (pLimits) { if (pLimits !== null && pLimits !== undefined) this.xmlAction.limits = pLimits; } - /* + /** * Setze den Filter. AD Syntax z.B (&(objectClass=person)(telephoneNumber=*)) - alle Personnen die ein Attribut telephoneNumber haben) * - * @param {String} filter req -der Filter. - * - * @return {void} - */ - this.setFilter = function (filter) + * @param {String} pFilter req -der Filter. + */ + this.setFilter = function (pFilter) { - if (filter !== null && filter !== undefined) - this.xmlAction.filter = filter; + if (pFilter !== null && pFilter !== undefined) + this.xmlAction.filter = pFilter; } } -/* +/** * Action um ein AD Eitrag zu erzeugen. * * @param {LoginData} login req -Logindaten @@ -923,91 +877,83 @@ function SearchAction (login, dn, attribute) * @param {LDAPIAttribute[]} attribute req - die Attribute des Eintrages * * @property String subContext DN neu zu erzeugenden Eintrages -*/ -function CreateAction( login, dn, attribute) + */ +function CreateAction (login, dn, attribute) { this.inheritFrom = BaseAction; this.inheritFrom("create", login, dn, attribute); this.subContext = ""; - /* + /** * Setzt DN neu zu erzeugenden Eintrages * - * @param {String} subContext req -DN neu zu erzeugenden Eintrages - * - * @return {void}. - */ - this.setSubContext = function (subContext) + * @param {String} pSubContext req -DN neu zu erzeugenden Eintrages + */ + this.setSubContext = function (pSubContext) { - if (subContext !== null && subContext !== undefined) - this.xmlAction.subContext = subContext; + if (pSubContext !== null && pSubContext !== undefined) + this.xmlAction.subContext = pSubContext; } - /* + /** * Fügt ein oder mehreren "structurelle" Attribute der Action hinzu. "structurelle" Attribute beschreiben den zu erzeugenden Eintrag. * Achtung! Es wird nicht überprüft, ob ein Wert eines Attributes bereits vorhanden ist! * Sondern es wird einfach hinzufügt. * - * @param {LDAPIAttribut\LDAPIAttribut[]\XML\XML[]} attr req Ein oder mehrere Attributennamen bzw. ein oder mehrere Attribute als XML. - * - * @return {void} + * @param {LDAPIAttribut\LDAPIAttribut[]\XML\XML[]} pAttribute req Ein oder mehrere Attributennamen bzw. ein oder mehrere Attribute als XML. */ - this.addEntryAttribute = function (attr) + this.addEntryAttribute = function (pAttribute) { - if (attr === null || attr === undefined) + if (pAttribute === null || pAttribute === undefined) return; //prüfe ob Knoten bereits existiert if(this.xmlAction.entryAttribute.length() <= 0) this.xmlAction.appendChild(<entryAttribute/>); - if(attr instanceof Array) - { - for (let i = 0; i < attr.length; i++) - this.addSingleEntryAttribute(attr[i]); - } - else - this.addSingleEntryAttribute(attr); + if (Array.isArray(pAttribute)) + { + for (let i = 0; i < pAttribute.length; i++) + this.addSingleEntryAttribute(pAttribute[i]); } + else + this.addSingleEntryAttribute(pAttribute); + } - /* - * Diese Methode prüft ob ein Attribut bereits existiert ist. Falls ein existiert denn wird der Wert dem Attribut hinzufügt. - * Falls nicht existiert wird das Attributt der Attributtenliste kommplett hinzufügt.] - * - * @param {XML} attr req - ein Attribut - * - * @return {void} - */ - this.addSingleEntryAttribute = function (attr) - { - var name = attr.getName(); - if (this.xmlAction.entryAttribute.attribute.(@name==name).length() == 0) - this.xmlAction.entryAttribute.appendChild(attr); + /** + * Diese Methode prüft ob ein Attribut bereits existiert ist. Falls ein existiert denn wird der Wert dem Attribut hinzufügt. + * Falls nicht existiert wird das Attributt der Attributtenliste kommplett hinzufügt.] + * + * @param {XML} pAttribute req - ein Attribut + */ + this.addSingleEntryAttribute = function (pAttribute) + { + var name = pAttribute.getName(); + if (this.xmlAction.entryAttribute.attribute.(@name==name).length() == 0) + this.xmlAction.entryAttribute.appendChild(pAttribute); else { - var valuesArray = attr.getValues(); + var valuesArray = pAttribute.getValues(); if (valuesArray !== undefined && valuesArray !== null) { - for(let i = 0; i < valuesArray.length; i++) + for (let i = 0; i < valuesArray.length; i++) { - this.addSingleEntryAttributeValue(name,valuesArray[i]); + this.addSingleEntryAttributeValue(name, valuesArray[i]); //this.xmlAction.entryAttribute.attribute.(@name==name).appendChild(<value>{valuesArray[i]}</value>) } } } } - /* + /** * Diese Methode prüft ob ein Attributenwert bereits existiert ist. Falls ein existiert denn wird der Wert ignoriert. * Falls nicht existiert wird der Wert der Werteliste hinzufügt.] * * @param {String} pName req - der Attributenname * @param {String} pValue req - der Attributenwert - * - * @return {void} - */ + */ this.addSingleEntryAttributeValue = function (pName, pValue) { for each (var val in this.xmlAction.entryAttribute.attribute.(@name==pName).value) @@ -1016,14 +962,12 @@ function CreateAction( login, dn, attribute) return; } this.xmlAction.entryAttribute.attribute.(@name==pName).appendChild(<value>{ - pValue - }</value>) -} - - + pValue + }</value>) + } } -/* +/** * Action um bestimmte oder alle Attribute, damit den Eintrag selber, enes AD Eintrages zu löschen. * * @param {LoginData} login req -Logindaten @@ -1031,10 +975,8 @@ function CreateAction( login, dn, attribute) * @param {LDAPIAttribute[]} attribute req - [Attribute auf die Action angewendet soll. * Achtung! null und leeres Araay sind zulüssig und spielen auch bei dieser Action eine wichtige Rolle! * null oder leeres Array für alle, damit den Eintrag selber löschen.] - * - * -*/ -function RemoveAction (login ,dn, attribute) + */ +function RemoveAction (login, dn, attribute) { this.inheritFrom = BaseAction; this.inheritFrom("remove", login, dn, attribute); diff --git a/process/ActiveDirectory_lib/process.js b/process/ActiveDirectory_lib/process.js index 581df23dd9861423abb85179df457a6f2061058c..03936d2e445566c8e897ffa347f62ff844203043 100644 --- a/process/ActiveDirectory_lib/process.js +++ b/process/ActiveDirectory_lib/process.js @@ -13,7 +13,8 @@ import("ActiveDirectoryXml_lib"); //TODO: add comments to methods -var ColumnMetadataProvider = (function () { +var ColumnMetadataProvider = (function () +{ var metadataInstance = {}; function _init(pTable) { diff --git a/process/activeDirectoryImport_serverProcess/process.js b/process/activeDirectoryImport_serverProcess/process.js index af3c0d1963c020d38b84a794e17838063b49e411..0c06426a2e47db1fa71704fc3c1be2594dd3c7d9 100644 --- a/process/activeDirectoryImport_serverProcess/process.js +++ b/process/activeDirectoryImport_serverProcess/process.js @@ -11,7 +11,8 @@ import("Util_lib"); import("Sql_lib"); import("KeywordRegistry_basic"); -if(!project.getPreferenceValue("custom.AD.active", false)){ +if (!project.getPreferenceValue("custom.AD.active", false)) +{ throw new Error ("ActiveDirectory import is not activated, please check the project Preferences") } @@ -40,7 +41,8 @@ var roleMapping = { "GroupName8" : "PROJECT_Workflow" }; -(function (){//keep everything in an encapsulated scope +(function () //keep everything in an encapsulated scope +{ var companyContactID = "b219b58a-f120-42d8-9a64-0b176501eac7"; // ToDo adapt to project var companyData = _getCompanyData(companyContactID); @@ -327,7 +329,8 @@ function _getCompanyData(pCompanyContactID) * * @returns {Object} comm Typs */ -function _getCustomeComTyps(){ +function _getCustomeComTyps() +{ return { commTypes: { "$virtual.PHONE": {