Guest User

Untitled

a guest
Oct 12th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. import React from 'react';
  2. import ActiveDirectory from 'activedirectory';
  3.  
  4. export default class ActiveDirectoryComponent extends React.Component {
  5. state = {
  6. authResponse: undefined
  7. };
  8.  
  9. componentDidMount() {
  10. var config = {
  11. url: 'ldap://compandomain.com:389',
  12. baseDN: 'dc=domainname,dc=com',
  13. username: 'user',
  14. password: 'pass'
  15. };
  16.  
  17. var ad = new ActiveDirectory(config);
  18. var username = 'john.smith@domain.com';
  19. var password = 'password';
  20.  
  21. ad.authenticate(username, password, function (err, auth) {
  22. if (err) {
  23. this.setState({ authResponse: { error: JSON.stringify(err) } });
  24. return;
  25. }
  26.  
  27. if (auth) {
  28. this.setState({ authResponse: auth });
  29. } else {
  30. console.log('Authentication failed!');
  31. this.setState({ authResponse: { authFailed: true } });
  32. }
  33. });
  34. }
  35.  
  36. render() {
  37. if (!this.state.authResponse) {
  38. return <div>Authenticating....</div>;
  39. }
  40. if (this.state.authResponse.error) {
  41. return <div>{this.state.authResponse.error}</div>
  42. }
  43. if (this.state.authResponse.authFailed) {
  44. return <div>Authentication Failed</div>
  45. }
  46. return <div>.....</div>
  47. }
  48. }
  49.  
  50. import ActiveDirectoryAuthentication from '../components/ActiveDirectoryAuthentication';
  51.  
  52. Uncaught TypeError: unknown stream type "undefined"
  53. at Logger.addStream (bunyan.js?a10b:620)
  54. at eval (bunyan.js?a10b:470)
  55. at Array.forEach (<anonymous>)
  56. at new Logger (bunyan.js?a10b:469)
  57. at Function.createLogger (bunyan.js?a10b:1618)
  58. at Object.eval (activedirectory.js?f995:16)
  59. at eval (990:1836)
  60. at Object.<anonymous> (bundle.js:1)
  61. at e (bundle.js:1)
  62. at eval (index.js?048a:1)
Add Comment
Please, Sign In to add comment