Guys I need help - I have SQL server and MS Access database. There is a form that I want to make accessible only for one group of people. I don't know how can I make it work - what I want to do is I want it to check what Domain User Group the user belongs to and then open this form (only if the user beloongs to that group that can have access to it). How can I do it? Any help would be very much appreciated!
Depends where you want to enforce that decision (and what versions of each you are using, of course). if you want sql server to decide, you need to ensure that the user is authenticating to that server *as* a member of that group (by this I mean it is that group that has been granted logon rights to the service, not all the users in that group), in which case I believe you'd be looking for a result from something along the lines of (in sql 2k8 at least): select name from sys.server_principals where sid = SUSER_SID() and type = 'WINDOWS_GROUP' then decide what to do with that. This is quesswork, by the way, I'm not in a position to try it out. I have to cast my mind way back to figure out the VBA side of things though, as I'd imagine ideally you'd just want to grey out the option in the app side without even trying to authenticate to the server to work this out (as it's possible for one person to be in multiple groups all of which would have access and they may be using the wrong SID to get there), in which case it would be a form load event validation calling a function like this : 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 Found that on my.advisor.com), last time I tried to do something like this it involved mr dan appleman and his indispensable API reference manuals under windows 95 and VB4 Good luck anyway.