Global

Methods

(async) WLdap(input, optopt) → {Promise}

Description:
  • 呼叫LDAP服務進行登入或取得使用者清單,係呼叫Net程式呼叫LDAP取得資料,故會有Net Framework版本與作業系統限制

    輸入(含帳密)經子程序之stdin交給Net程式,不出現在程序之命令列;只轉交mode、account、password、ldappath,不改動呼叫端之input

Source:
Example
import WLdap from 'w-ldap'

async function test() {
    let inp
    let r
    let account = '{account}'
    let password = '{password}'
    let ldappath = 'LDAP://{PATH}'

    inp = {
        mode: 'logIn',
        account,
        password,
        ldappath,
    }
    r = await WLdap(inp)
    console.log('logIn', r)
    w.fsWriteText('logIn.txt', w.o2j(r, true))

    inp = {
        mode: 'listUsers',
        account,
        password,
        ldappath,
    }
    r = await WLdap(inp)
    w.fsWriteText('listUsers.txt', w.o2j(r, true))

}
test()
    .catch((err) => {
        console.log('catch', err)
    })
Parameters:
Name Type Attributes Default Description
input Object

輸入呼叫資料物件

Properties
Name Type Description
mode String

輸入呼叫方法字串,可有'logIn'與'listUsers'

account String

輸入LDAP帳號字串

password String

輸入LDAP帳號之密碼字串

ldappath String

輸入LDAP伺服器位址字串

opt Object <optional>
{}

輸入設定物件,預設{}

Properties
Name Type Attributes Default Description
ver String <optional>
'4.8'

輸入調用windows程序之Net Framework版本字串,可有'4.5'、'4.6'、'4.7.2'與'4.8',預設'4.8'

timeout Number <optional>

輸入逾時毫秒數正整數,逾時將強制結束Net程式並reject,未給或非正整數時不設限(實際上限為計時器上限約24.8天)。LDAP伺服器接受連線卻不回應時,Net程式約240秒後自行以錯誤結束

Returns:

回傳Promise。resolve回傳成功資料:logIn為該帳號之LDAP條目,帳密驗證成功但以samaccountname查無該帳號條目時回傳{success:null};listUsers為使用者條目陣列。reject一律回傳錯誤訊息字串:輸入檢查失敗為說明字串;LDAP回報之錯誤為其原始訊息;Net程式啟動失敗以'spawn['開頭;Net程式以非0結束以'code['開頭;逾時以'timeout['開頭;Net程式結束但未產生輸出檔為'connLDAP exited without output file';輸出內容不合格式以'invalid output from connLDAP:'開頭

Type
Promise