本文介绍了在MS Access 2007中使用Active Directory/Windows身份验证对用户进行身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有基于MSAccess 2007构建的应用程序.我们想为此应用程序添加新的用户登录概念.我想使用Active Directory/Windows身份验证对用户进行身份验证.我想为此用户创建一个日志文件. (就像我们对使用表单身份验证的.net应用程序所做的一样)如何在MS Access 2007上做到这一点.

We have application built on MSAccess 2007. We want to add a new user login concept for this application.I want to Authenticate user using Active Directory/Windows authentication.I want create a log file for this user. (like we do for .net applications using forms authentication)How do I do that on MS Access 2007.

此外,此应用程序将运行24小时,不会关闭.可能有多个用户使用此应用程序.正如我所说的,此应用程序使用24/7,有多个班次运行,并且不同的用户登录和注销.在用户登录和注销会话期间,我们需要跟踪特定用户的日志.此应用程序使用SQL Server 2005作为数据库服务器.
您的建议对我很有帮助,在MS Access 2007上开发此类模块

Furthermore this application runs 24 hours, it will not be shutdown. There can be multiple users using this application.As I said this application is used 24/7, There are multiple shifts running and different users login and logout.During the user login and logout session, we need to keep track of the log for a particular user.This application uses SQL server 2005 as database server.
Your advise is a great help for me, to develop this kind of module on MS Access 2007

推荐答案

由于用户必须登录到PC,因此您可以使用 http://www.mvps.org/access/api/api0008.htm :

Since the user has to log on to the pc, then you can simply grab their logon by using the code from http://www.mvps.org/access/api/api0008.htm:

' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
    "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
    strUserName = String$(254, 0)
    lngLen = 255
    lngX = apiGetUserName(strUserName, lngLen)
    If ( lngX > 0 ) Then
        fOSUserName = Left$(strUserName, lngLen - 1)
    Else
        fOSUserName = vbNullString
    End If
End Function

而且,以下是vbs脚本,但它也可以在Access中正常工作:

And, the following is a vbs script, but it should work in Access just fine also:

显示组成员身份和Active Directory位置

Set objGroup = GetObject("LDAP://cn=GroupName,ou=OUName,DC=DomainName,DC=local")
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Set objFile = objFileSystem.OpenTextFile(objGroup.Get("name") & " – Members.txt", 2, True, 0)
For Each objMember in objGroup.Members
  objFile.WriteLine objMember.Get("sAMAccountName") & VbTab & _
    objMember.Get("cn") & VbTab & _
    objMember.Parent
Next
Set objFile = Nothing
Set objFileSystem = Nothing
Set objGroup = Nothing

这篇关于在MS Access 2007中使用Active Directory/Windows身份验证对用户进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 08:05
查看更多