ldap使用Cavde命令批量导入用户数据并设置初始化密码和启用

一、建立导入模板

用excel或者记事本都可以,保存为CSV格式

记事本格式:
记事本格式
excel格式:
excel格式
二、使用csvde命令导入

数据文件整理好之后用管理员身份运行cmd使用命令进行批量导入:
Csvde -i -f c:\aduser.csv
导入命令
三、启用用户并更改初始密码

用户都导入成功后使用此命令初始化用户的密码与启用用户:
dsquery user “ou=it,ou=user,ou=test,dc=abc,dc=cn” | dsmod user -pwd P@ssw0rd -mustchpwd yes –disabled no
密码初始化与启用
此命令设置默认密码 p@ssw0rd ,下次登陆必须更改密码,启用用户

附上用户属性表:

用户账户属性

“常规”标签

Sn

Givename

英文缩写

Initials

显示名称

displayName

描述

Description

办公室

physicalDeliveryOfficeName

电话号码

telephoneNumber

电话号码

其他otherTelephone 多个以英文分号分隔

电子邮件

Mail

网页

wWWHomePage

网页

其他url多个以英文分号分隔

“地址”标签

国家/地区

C 如:中国CN,英国GB

省/自治区

St

市/县

L

街道

streetAddress

邮政信箱

postOfficeBox

邮政编码

postalCode

“账户”标签

用户登录名

userPrincipalName 形如:S1@benet.com

用户登录名

(以前版本)

sAMAccountName 形如:S1

登录时间

logonHours

登录到

userWorkstations多个以英文逗号分隔

用户账户控制

userAccountControl

(启用:512,禁用:514,密码永不过期:66048)

账户过期

accountExpires

“配置文件”标签

配置文件路径

profilePath

登录脚本

scriptPath

主文件夹

本地路径 homeDirectory

连接 homeDrive(盘符)

到 homeDirectory

“电话”标签

家庭电话

homePhone(若是其他,在前面加other)

寻呼机

Pager 如:otherhomePhone

移动电话

mobile若多个以英文分号分隔

传真

FacsimileTelephoneNumber

IP电话

ipPhone

注释

Info

“单位”标签

职务

Title

部门

Department

公司

Company

“隶属于”标签

隶属于

memberOf 用户组的DN不需要使用引号,多个用分号分隔

“拨入”标签

远程访问权限

(拨入或×××)

msNPAllowDialin

(允许访问值为:TRUE ;拒绝访问值为:FALSE)

回拨选项

msRADIUSServiceType

(由呼叫方设置或回拨到 值:4)

总是回拨到

msRADIUSCallbackNumber

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用Spring Boot集成LDAP实现AD域用户认证、用户检索和密码重置,需要进行以下步骤: 1. 添加Spring LDAP和Spring Security依赖 首先,在pom.xml文件中添加Spring LDAP和Spring Security依赖: ```xml <dependency> <groupId>org.springframework.ldap</groupId> <artifactId>spring-ldap-core</artifactId> <version>2.3.3.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-ldap</artifactId> <version>5.4.6</version> </dependency> ``` 2. 配置LDAP连接信息 在application.properties文件中配置LDAP连接信息,如下所示: ```properties # LDAP server URL spring.ldap.urls=ldap://ad.example.com:389/ # LDAP base DN spring.ldap.base=dc=example,dc=com # LDAP user DN spring.ldap.username=cn=admin,dc=example,dc=com # LDAP user password spring.ldap.password=secret ``` 3. 配置Spring Security认证 在SecurityConfig类中配置Spring Security认证: ```java @Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/login").permitAll() .anyRequest().authenticated() .and() .formLogin() .loginPage("/login") .defaultSuccessUrl("/home") .failureUrl("/login?error=true") .permitAll() .and() .logout() .logoutSuccessUrl("/login") .permitAll(); } @Override public void configure(AuthenticationManagerBuilder auth) throws Exception { auth .ldapAuthentication() .userDnPatterns("uid={0},ou=people") .groupSearchBase("ou=groups") .contextSource() .url("ldap://ad.example.com:389/dc=example,dc=com") .and() .passwordCompare() .passwordEncoder(new BCryptPasswordEncoder()) .passwordAttribute("userPassword"); } } ``` 这里,我们使用LDAP进行用户认证,用户DN格式为`uid={0},ou=people`,组DN为`ou=groups`。同时,我们使用BCrypt密码编码器进行密码加密。 4. 实现用户检索和密码重置 我们可以使用LdapTemplate类来检索用户和重置密码。例如,检索所有用户的代码如下: ```java @Autowired private LdapTemplate ldapTemplate; public List<String> findAllUsers() { return ldapTemplate.search( LdapQueryBuilder.query().where("objectclass").is("person"), (AttributesMapper<String>) attrs -> (String) attrs.get("cn").get() ); } ``` 重置密码的代码如下: ```java @Autowired private LdapTemplate ldapTemplate; public void resetPassword(String username, String newPassword) { Name dn = LdapNameBuilder .newInstance() .add("ou", "people") .add("uid", username) .build(); ModificationItem[] mods = new ModificationItem[] { new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute("userPassword", newPassword)) }; ldapTemplate.modifyAttributes(dn, mods); } ``` 这里,我们使用LdapNameBuilder类构建用户DN,然后使用ModifyAttributes方法重置用户密码。 以上就是使用Spring Boot集成LDAP实现AD域用户认证、用户检索和密码重置的步骤。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值