gpt4 book ai didi

ms-access - MS Access 有没有办法获取当前的 Active Directory 用户?

转载 作者:行者123 更新时间:2023-12-03 06:34:12 24 4
gpt4 key购买 nike

我正在为我的公司制定一个软件规范,作为审核系统的一部分,我认为如果有一种方法可以获取当前的 Active Directory 用户,那就太好了。

希望是这样的:

Dim strUser as String
strUser = ActiveDirectory.User()
MsgBox "Welcome back, " & strUser

最佳答案

Try this article - 我有一些正在工作的代码,如果没有的话,它会工作......

相关引用:

Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal IpBuffer As String, nSize As Long) As Long
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long

Function ThisUserName() As String
Dim LngBufLen As Long
Dim strUser As String

strUser = String$(15, " ")
LngBufLen = 15

If GetUserName(strUser, LngBufLen) = 1 Then
ThisUserName = Left(strUser, LngBufLen - 1)
Else
ThisUserName = "Unknown"
End If
End Function

Function ThisComputerID() As String
Dim LngBufLen As Long
Dim strUser As String

strUser = String$(15, " ")
LngBufLen = 15

If GetComputerName(strUser, LngBufLen) = 1 Then
ThisComputerID = Left(strUser, LngBufLen)
Else
ThisComputerID = 0
End If
End Function

关于ms-access - MS Access 有没有办法获取当前的 Active Directory 用户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9052/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com