我有这个简单的React组件来处理Active Directory身份验证:
import React from 'react';
import ActiveDirectory from 'activedirectory';
export default class ActiveDirectoryComponent extends React.Component {
state = {
authResponse: undefined
};
componentDidMount() {
var config = {
url: 'ldap://compandomain.com:389',
baseDN: 'dc=domainname,dc=com',
username: 'user',
password: 'pass'
};
var ad = new ActiveDirectory(config);
var username = 'john.smith@domain.com';
var password = 'password';
ad.authenticate(username, password, function (err, auth) {
if (err) {
this.setState({ authResponse: { error: JSON.stringify(err) } });
return;
}
if (auth) {
this.setState({ authResponse: auth });
} else {
console.log('Authentication failed!');
this.setState({ authResponse: { authFailed: true } });
}
});
}
render() {
if (!this.state.authResponse) {
return <div>Authenticating....</div>;
}
if (this.state.authResponse.error) {
return <div>{this.state.authResponse.error}</div>
}
if (this.state.authResponse.authFailed) {
return <div>Authentication Failed</div>
}
return <div>.....</div>
}
}
当我尝试使用此组件时:
import ActiveDirectoryComponent from '../components/ActiveDirectoryAuthentication';
我的应用程序未加载,我在控制台中收到此错误:
Uncaught TypeError: unknown stream type "undefined"
at Logger.addStream (bunyan.js?a10b:620)
at eval (bunyan.js?a10b:470)
at Array.forEach (<anonymous>)
at new Logger (bunyan.js?a10b:469)
at Function.createLogger (bunyan.js?a10b:1618)
at Object.eval (activedirectory.js?f995:16)
at eval (990:1836)
at Object.<anonymous> (bundle.js:1)
at e (bundle.js:1)
at eval (index.js?048a:1)
任何想法都需要设置什么才能使Bunyan正常播放视频流吗? 在我看来,这似乎是“活动目录”模块中的问题,因为我认为它应该通过Bunyan正确创建流。但是我不确定,因为我是React的新手。
更新(10/31/2018):'activedirectory'模块可在Javascript中完美运行。上面的问题仅在React中可见。我必须编写一个单独的Javascript应用程序才能与activedirectory交互,然后从我的React应用程序中使用它。虽然这是一种解决方法,但如果解决了上述问题,使所有代码都在React中,那就很好了。
答案 0 :(得分:2)
Github上的activedirectory模块上有一个打开的请求,该请求可以解决以下问题:https://github.com/gheeres/node-activedirectory/pull/150/files
我在本地尝试过,它可以解决问题。希望PR将最终合并。