本文介绍了确定用户的组成员身份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何确定用户(例如 Access)是否是 Active Directory 安全组的成员?

How can I determine if a user, in say Access, is a member of an Active Directory Security Group?

我宁愿不在我的小型 Access DB 中构建整个身份验证系统.

I'd rather not build a whole authentication system into my little Access DB.

谢谢

推荐答案

Allain 找到了这个在线

Function IsMember(strDomain As String, strGroup _
  As String, strMember As String) As Boolean
  Dim grp As Object
  Dim strPath As String

  strPath = "WinNT://" & strDomain & "/"
  Set grp = GetObject(strPath & strGroup & ",group")
  IsMember = grp.IsMember(strPath & strMember)
End Function

您可以通过 USERDOMAINUSERNAME 环境变量获取 Windows 帐户信息:

You can get the Windows account info by way of the USERDOMAIN and USERNAME environment vars:

Function GetCurrentUser() As String
    GetCurrentUser = Environ("USERNAME")
End Function

Function GetCurrentDomain() As String
    GetCurrentDomain = Environ("USERDOMAIN")
End Function

综合起来:

If IsMember(GetCurrentDomain, "AD Group", GetCurrentUser) Then
   DoStuff()
End If

这篇关于确定用户的组成员身份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 19:41