Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
2501-Initial-check-in.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2501-Initial-check-in.patch of Package erlang
From 456bdeae962beb94f8e5cafba671aa27f8456421 Mon Sep 17 00:00:00 2001 From: "Linus.yuan" <yuan_shijiang@163.com> Date: Mon, 8 Jun 2020 08:29:11 +0800 Subject: [PATCH] Initial check in. To windows Active Domain, get user last password attribute is common task, this simple code guide you how to implement via erlang way. --- lib/eldap/example/ad_expiring_account.erl | 50 +++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 lib/eldap/example/ad_expiring_account.erl diff --git a/lib/eldap/example/ad_expiring_account.erl b/lib/eldap/example/ad_expiring_account.erl new file mode 100644 index 0000000000..b103f7f521 --- /dev/null +++ b/lib/eldap/example/ad_expiring_account.erl @@ -0,0 +1,50 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1996-2018. All Rights Reserved. +%% +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. +%% +%% %CopyrightEnd% +%% + +expired_account(Ou) -> + {ok,{eldap_search_result,X,[]}} = users(Ou), + process(X). + +users(Ou) -> + {_,S}=eldap:open(["xxx.xxx.xxx.xxx"]), + eldap:simple_bind(S,"loginname@domainname","password"), + eldap:search(S,[{base,"OU=" ++ Ou ++ "OU=China,DC=example,DC=net"},{filter,eldap:present("objectClass")},{attributes,["cn","mail","pwdLastSet"]}]). + + +process( [{eldap_entry, Ou,[{"cn",[Cn]},{"pwdLastSet",[Pwd]},{"mail",[Mail]}]} | Rest] )-> + io:format("~p: ~p ~p~n",[Cn,caculate_pwddate(Pwd),Mail]), + process(Rest); + +process( [{eldap_entry, Ou,[{"cn",[Cn]},{"pwdLastSet",[Pwd]}]} | Rest] )-> + io:format("~p: ~p~n",[Cn,caculate_pwddate(Pwd)]), + process(Rest); + +process([_]) -> + root; + +process([]) -> + ok. + +caculate_pwddate(Pwd) -> + _Date = round(erlang:list_to_integer(Pwd)/10000000 - 11644473600), + Base = calendar:datetime_to_gregorian_seconds({{1970,1,1},{0,0,0}}), + Seconds = Base + _Date, + { Date,_Time} = calendar:gregorian_seconds_to_datetime(Seconds), + Date. -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor