Excel - 根据 Excel 工作表中的显示名称从 AD 获取用户名
我有一张员工的 Excel 工作表,其中包含有关他们的所有信息。我正在尝试将此信息导入 AD,但为了做到这一点,我还需要获取这些用户的用户名。我想要 vba 代码或 vb.net 代码基本上获取 D 列中每一行的值并在 AD 中查找它并返回用户名并将其添加到 A 列。这样的事情可能吗?
So I've got this Excel sheet of employees which have all the information about them. I'm trying to import this info into AD, but in order to do that I need to get the username for these users as well. And I would like vba code or vb.net code that basically takes the value of every row in column D and looks for it in AD and returns the username and adds it to column A. Would something like this be possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ADO.NET 可以实现这一点。我无法在当前环境中尝试它,但我过去已经成功使用过它:
添加对 ADO 类型库 (msadoXX.dll) 的引用。
使用您自己的凭据创建与 ActiveDirectory 的连接。有时,它无需指定您的凭据(单点登录)即可工作:
接下来创建一个命令:
然后执行查询命令:
当然,您必须根据您的需要调整查询。
It is possible with ADO.NET. I can't try it in my current environment but I've used it successfully in the past:
Add a reference to the ADO type library (msadoXX.dll).
Create a connection to ActiveDirectory using your own credentials. Sometimes it works without specifying your credentials (single sign on):
Next create a command:
Then execute the query command:
Of course, you'll have to adapt the query to your needs.