scripting@wanadoo.nl




TranslateName()

http://www.scriptlogic.com/kixtart/FunctionLibrary_FunctionList.aspx


actual FunctionLibrary list on 'Scriptlogic' site printer-friendly mirror of UDF topic on 'scripting@wanadoo.nl' site close
5 April 2002 TranslateName()
AuthorHoward A. Bullock
Action Translates from one name type to another. Good for converting an NT4 type name like domain\user into an LDAP distinguished name used in Active Directory or the reverse.
SyntaxTranslateName ($InitType, $BindName, $LookupNameType, $LookupName, $ReturnNameType) 
Parameters
  • $InitType (Required / Numeric) 1 = ADS_NAME_INITTYPE_DOMAIN (Initializes a NameTranslate object by setting the domain that the object will bind to), 2 = ADS_NAME_INITTYPE_SERVER (Initializes a NameTranslate object by setting the server that the object)
  • $BindName (Required / String) if an $InitType = 3 (ADS_NAME_INITTYPE_GC), then the $BindName = "". InitTypes 1 and 2 require a name of a domain or server to be input. Note: '"' may default to the current server or domain.
  • $LookupNameType (Required / Numeric) See list of types under $ReturnNameType
  • $LookupName (Required / String) Text of name to lookup. "domain\user" or distinguished name. Other types may work as well when the proper $LookupNameType is used.
  • $ReturnNameType (Required / String) Documentation of Name Types. Lookup the more info on "http://msdn.microsoft.com". Not all name types work. The two that have been most useful to are "1" and "3". 1 = ADS_NAME_TYPE_1779 name format as specified in RFC 177. 
  • RemarksVersion 2 Not all name types seem to work. 
    ReturnsThis function returns an ARRAY of three values:
    - Name of the type specified by $ReturnNameType (String)
    - Error number (Long Integer)
    - Error text (String) 
    DependenciesOS: Active Directory aware client 
    Examples
    $DN = TranslateName (3, "", 3, "@Domain\@wksta$", 1)
    ? "DN = " + $DN[0]
    ? "Error = " + $DN[1]
    ? "ErrorText = " + $DN[2]
    
    $DN = TranslateName (3, "", 3, "@LDomain\@userid", 1)
    ? "DN = " + $DN[0]
    ? "Error = " + $DN[1]
    ? "ErrorText = " + $DN[2]
    
     
    Source
    FUNCTION TranslateName ($inittype, $bindname, $lookupnametype, $lookupname, $returnnametype)
      DIM $inittype, $bindname, $lookupnametype, $lookupname, $returnnametype
      DIM $nametranslate, $returnname, $error, $errortext
    
      $error = 0
      $errortext = ""
      $returnname = ""
      $nametranslate = CreateObject ("NameTranslate")
      $error = @error
      $errortext = @serror
      IF ($error = 0)
        $nametranslate.init ($inittype, $bindname)
        $error = @error
        $errortext = @serror
        IF ($error = 0)
          $nametranslate.set ($lookupnametype, $lookupname)
          $error = @error
          $errortext = @serror
          IF ($error = 0)
            $returnname = $nametranslate.get($returnnametype)
            $error = @error
            $errortext = @serror
          ENDIF
        ENDIF
      ENDIF
      $translatename = $returnname, $error, $errortext
    ENDFUNCTION ; - TranslateName -
     
      original source of UDF topic. show actual FunctionLibrary list on Scriptlogic site close top
              printer-friendly mirror of UDF topic on scripting@wanadoo.nl site  




    Copyright © 2003 www.scriptlogic.com & scripting@wanadoo.nl - last updated on 20 May 2003


    Site Meter