Active directory 使用Elixir/Erlang根据AD验证凭据
我试图用Elixir/Erlang实现简单的AD凭证验证。我在Active directory 使用Elixir/Erlang根据AD验证凭据,active-directory,erlang,elixir,Active Directory,Erlang,Elixir,我试图用Elixir/Erlang实现简单的AD凭证验证。我在C#中的代码运行良好 C# 长生不老药 defmodule AD do @moduledoc false require Logger @format [ limit: :infinity, pretty: true, structs: true, width: 210, syntax_colors: [number: :yellow, atom: :cyan, string: :
C#
中的代码运行良好
C#
长生不老药
defmodule AD do
@moduledoc false
require Logger
@format [
limit: :infinity,
pretty: true,
structs: true,
width: 210,
syntax_colors: [number: :yellow, atom: :cyan, string: :green, boolean: :magenta, nil: :magenta]
]
def test do
{:ok, pid} = :eldap.open(['132.10.100.156'], log: &log/3)
:eldap.simple_bind(pid, 'my-username', 'my-password')
end
def log(_, format_string, format_args) do
Logger.debug(inspect({format_string, format_args}, @format))
end
end
控制台:
iex> AD.test
[2019-11-16 18:23:53.354] {'bind request = ~p~n', [{:BindRequest, 3, 'my-username', {:simple, 'my-password'}}]}
{:error, :invalidCredentials}
[2019-11-16 18:23:53.511] {'bind reply = ~p~n',
[
ok: {:LDAPMessage, 1,
{:bindResponse,
{:BindResponse, :invalidCredentials, [],
[56, 48, 48, 57, 48, 51, 48, 56, 58, 32, 76, 100, 97, 112, 69, 114, 114, 58, 32, 68, 83, 73, 68, 45, 48, 67, 48, 57, 48, 51, 67, 56, 44, 32, 99, 111, 109, 109, 101, 110, 116, 58, 32, 65, 99, 99, 101, 112,
116, 83, 101, 99, 117, 114, 105, 116, 121, 67, 111, 110, 116, 101, 120, 116, 32, 101, 114, 114, 111, 114, 44, 32, 100, 97, 116, 97, 32, 53, 50, 101, 44, 32, 118, 50, 53, 56, 48, 0], :asn1_NOVALUE,
:asn1_NOVALUE}}, :asn1_NOVALUE}
]}
iex>
:erldap
需要我的-username@somedomain或完整的DN
,以便正常工作
iex> AD.test
[2019-11-16 18:23:53.354] {'bind request = ~p~n', [{:BindRequest, 3, 'my-username', {:simple, 'my-password'}}]}
{:error, :invalidCredentials}
[2019-11-16 18:23:53.511] {'bind reply = ~p~n',
[
ok: {:LDAPMessage, 1,
{:bindResponse,
{:BindResponse, :invalidCredentials, [],
[56, 48, 48, 57, 48, 51, 48, 56, 58, 32, 76, 100, 97, 112, 69, 114, 114, 58, 32, 68, 83, 73, 68, 45, 48, 67, 48, 57, 48, 51, 67, 56, 44, 32, 99, 111, 109, 109, 101, 110, 116, 58, 32, 65, 99, 99, 101, 112,
116, 83, 101, 99, 117, 114, 105, 116, 121, 67, 111, 110, 116, 101, 120, 116, 32, 101, 114, 114, 111, 114, 44, 32, 100, 97, 116, 97, 32, 53, 50, 101, 44, 32, 118, 50, 53, 56, 48, 0], :asn1_NOVALUE,
:asn1_NOVALUE}}, :asn1_NOVALUE}
]}
iex>