altriox
Hi,
I’m trying to use the eldap module to set a password for a new user in Active Directory. In AD, the default attribute for setting the password is unicodePwd, and uses a UTF-16. When I try to set the attribute using eldap I get an {:error, :unwillingToPerofrm} back. I know I need to encode the password, but I’m not quite sure how.
:application.ensure_all_started(:ssl)
{:ok, handle} = :eldap.open(['example.local'], [{:port,636}, {:ssl, true}])
authenticated =
:ok == :eldap.simple_bind(handle,
'CN=Administrator Account,CN=Users,DC=example,DC=local',
'password')
:eldap.add(handle, 'cn=John K Doe,cn=Users,dc=example,dc=local',
[{'objectclass', ['user']},
{'displayName', ['John K. Doe']},
{'givenName', ['John']},
{'initials', ['K']},
{'sn', ['Doe']},
{'sAMAccountName', ['john.k.doe']},
{'userPrincipalName', ['john.k.doe@example.local]},
{'cn', ['John K Doe']},
{'unicodePwd', ['abc@123!']}, # => { :error, :unwillingToPerform }
])
:eldap.close(handle)
I was able to get similar code to work in golang:
// Encoding password
utf16 := unicode.UTF16(unicode.LittleEndian, unicode.IgnoreBOM)
encoded, err := utf16.NewEncoder().String("\"abc@123!\"")
// Building Add Request for User Object
addReq := ldap.AddRequest{
DN: "CN=John W Doe,CN=Users,DC=example,DC=local",
Attributes: []ldap.Attribute{
ldap.Attribute{"objectClass", []string{"user"}},
ldap.Attribute{"displayName", []string{"John W. Doe"}},
ldap.Attribute{"givenName", []string{"John"}},
ldap.Attribute{"sn", []string{"Doe"}},
ldap.Attribute{"initials", []string{"W"}},
ldap.Attribute{"sAMAccountName", []string{"john.w.doe"}},
ldap.Attribute{"userPrincipalName", []string{"john.w.doe@example.local"}},
ldap.Attribute{"unicodePwd", []string{encoded}},
ldap.Attribute{"userAccountControl", []string{"512"}},
},
}
Any help would be most appreciated.
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m aware of 2 such projects, are there others?
git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
Hi all,
I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
Hi everyone.
My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
Hi,
we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley:
Mutonex gamedesign was finish...
New
Hello
I’ve been coding in Elixir for almost two years now because of my current job where we implemented Elixir in our application. But ...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #hex











Showing Posts 1 to 3- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
jwarlander
It looks like the
:unicodemodule in Erlang should be able to help converting the data, just like your golang example does:On my phone now, so I can’t experiment with it unfortunately..
OvermindDL1
Also, I made a binary based LDAP module for Elixir, it is read-only currently but I left it open for future development to be expanded if you want to make a PR for it. The interface is quite a bit nicer.
altriox
Thanks, the :unicode module fixed my problem. Below is what I changed:
This creates an account with the password abc@123!, and enables it. I was able to log in using the password. It took me a little longer than I want to admit due to using a simpler password that wasn’t meeting the password policy which also gives you the :unwillingToPerform error.
@OvermindDL1 your module looks awesome. I’ll definitely keep it in mind. I’m very new to Elixir/Erlang and programming in general. This was basically a proof of concept for me, in order to see if I could get Elixir to do what I need. It took me quite a while to figure out how to parse the search results from :eldap. Once I get a few more books on Elixir under my belt, I plan to come back to it.
Thank you both for your help.