Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default is a database user a member of a group in active directory

Hi all,

I am currently building a database in Access 2010. At the moment the database is opened a log-in appears, asking for username and password.

These are checked with the data in Active Directory.

The unique username is then in vba lookup in a query and 'user' and 'role' are defined. These are public variables, remaining there value throughout the session.

Code:
------------------------------------------
Private Sub cmdLogin_Click()

myuser = Me.txtuser.Value
mypwd = Me.txtpwd.Value

recognized = Authenticated(myuser, mypwd)

If recognized = True Then

role = DLookup("Job", "qryUserNameCheck", "Windowsname = '" & Me.txtuser.Value & "'")
user = DLookup("SCMID", "qryUserNameCheck", "Windowsname = '" & Me.txtuser.Value & "'")

DoCmd.Close acForm, "frmAuthenticUserLogIn"
DoCmd.OpenForm "MainInterface"
Exit Sub
Else

MsgBox "Not recognized.", vbOKOnly, "Sorry"
Me.txtpwd.Value = ""
Me.txtuser.Value = ""

raisetries
If Logintries = 3 Then
DoCmd.Quit acQuitSaveNone
End If

End If

End Sub
------------------------------------------------
The function Authenticated checks the Active directory for windows username and windows password.

code
-----------------------------------------------
Function Authenticated(strUserID As String, strPassword As String, Optional strDNSDomain As String = "") As Boolean

If strDNSDomain = "" Then
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
End If

Set dso = GetObject("LDAP:")
On Error Resume Next
Err.Clear
Set ou = dso.OpenDSObject("LDAP://" & strDNSDomain, strUserID, strPassword, 1)
Authenticated = (Err.Number = 0)

End Function
------------------------------------------------
I found this function on the internet and works like a charm.

As you can see, the role of the logged in user is defined by the field Job in the query qryUsernameCheck.
This also works as it should.
But, Quality Assessment demands that the role of the user in the database is defined by the question if the user is a member of a group in Active Directory.
So, we asked IT to add a few groups on active directory (project-adm, project-mgt, project-wfl) and also add a few users to each group.
Now, my question is: how do i check with vba if a user is a member of one of these groups, so that the role in the database is defined.

Any help is greatly appreciated.

Sybolt
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listing Active Directory groups that have directory access rights [email protected] Excel Programming 0 October 17th 08 03:13 PM
Member database question! Lars Grøtteland Excel Worksheet Functions 0 September 6th 06 01:57 PM
PivotTable with Member Property - how to subtotal on Member Proper swordsman Excel Programming 0 June 23rd 06 10:01 PM
condition - member of a group elbows Excel Discussion (Misc queries) 3 March 13th 06 05:57 PM
Determining the group a picture or textbox is a member of David Cuthill[_2_] Excel Programming 6 February 12th 04 05:45 PM


All times are GMT +1. The time now is 11:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"