RE: NT Authentication

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Derek Wittman (anonymous_at_discussions.microsoft.com)
Date: 03/19/04


Date: Fri, 19 Mar 2004 08:26:16 -0800

I figured it out. I had some typos in the code. (modified by myself)
Thanks!
Derek
     
     ----- Br1an_g wrote: -----
     
     derek,
     
     is this a different issue from the authentication?
     
     or is it the code that i originally posted that is giving
     this error?
     
     
>-----Original Message-----
>I don't anticipate any errors. (famous last words, I'm
     sure).
>>However, each time I'm INSERTing or UPDATEing into
     tables, I have a timestamp that gets updated and I want to
     update or insert (respectively) the lpUserName as well.
     Unfortunately, I'm getting an error message that my
     function lpUserName is undefined. I've made my
     switchboard module Public, but I need to define my
     function. I normally don't have things running outside of
     the sub/function which call them, so I'm at a loss. Can
     you suggest something that would work?
>>Thank you!
>Derek
>> ----- Br1an_g wrote: -----
>> HI derek,
>> the unable to get name section is if an error occurs
     and
> the code cannot get the NT sign on of the user.
>> you would need to add another level of check before
> the 'Else'
>> e.g.
> Dim dbs as Database
> Dim rst as recordset
>> set dbs = CurrentDb
>> dbs.Execute "SELECT UserNamePermissions " _
>& "INTO SQLTemp " _
>& "FROM tblSecurity " _
>& "WHERE UserNamePermissions = '" & lpUserName
     & "';"
>> 'open the new SQLTemp table
> Set rst = dbs.OpenRecordset("SQLTemp")
>> 'check if there are records in the temp table
> If rst.RecordCount > 0 Then
> 'username exists apply permissions
> else
> 'username does not exist deny permission
> end if
>> 'Tidy up - Delete the temp table
> dbs.Execute "DROP TABLE SQLTemp;"
>> Hope that makes sense
>> Brian
>>>-----Original Message-----
>>This is fantastic. Thank you very much.
>>>And I assume that the "Unable to get the name"
     portion
> can be used to deny access to the database?
>>>Thanks!
>>Derek
>>> ----- Br1an_g wrote: -----
>>> heres how to get the current NT sign on (from
> knowledge
>> base):
>> function goes in a module
>> the rest in the module of the form (prob
     switchboard)
>>> then you can do a select statment to retrieve
     the
> user
>> permissions from your table where
> lpUserName=tblUserName
>>> [code]
>> ' Declare for call to mpr.dll.
>> Declare Function WNetGetUser Lib "mpr.dll" _
>> Alias "WNetGetUserA" (ByVal lpName As
     String, _
>> ByVal lpUserName As String, lpnLength As
     Long)
> As
>> Long
>>> Const NoError = 0 'The Function call
     was
>> successful
>>> Sub GetUserName()
>>> ' Buffer size for the return string.
>> Const lpnLength As Integer = 255
>>> ' Get return buffer space.
>> Dim status As Integer
>>> ' For getting user information.
>> Dim lpName, lpUserName As String
>>> ' Assign the buffer size constant to
> lpUserName.
>> lpUserName = Space$(lpnLength + 1)
>>> ' Get the log-on name of the person
     using
> product.
>> status = WNetGetUser(lpName, lpUserName,
> lpnLength)
>>> ' See whether error occurred.
>> If status = NoError Then
>> ' This line removes the null
     character.
> Strings
>> in C are null-
>> ' terminated. Strings in Visual Basic
     are
> not
>> null-terminated.
>> ' The null character must be removed
     from
> the C
>> strings to be used
>> ' cleanly in Visual Basic.
>> lpUserName = Left$(lpUserName, InStr
> (lpUserName,
>> Chr(0)) - 1)
>> Else
>>> ' An error occurred.
>> MsgBox "Unable to get the name."
>> End
>> End If
>>> ' Display the name of the person logged
     on to
> the
>> machine.
>> MsgBox "The person logged on this
     machine
> is: " &> lpUserName
>>> End Sub
>> [/code]
>>>-----Original Message-----
>>>Good morning,
>>>Rather than requiring users to logon to a new
> database
>> (no longer the Labor Standards Request - I'm
     doing a
>> Budget/Expense tracking and PO preparation
     deal
> now), I'd
>> like to compare the NT userID from the "client
     PC"
> with a
>> table of users who are allowed to use the
> application.
>> I'm not so much (at the moment) concerned
     about user
>> levels (of course, I'll be administrator), but
     I
> will need
>> to compare to a table of users...
>>>>If I can set userlevel by a usertable (with the
> list of
>> NT IDs), then I can allow or not allow certain
     menus
> to be
>> seen, etc.
>>>>I've checked the ng archives and found nothing.
> I'm
>> posting here, then I will go to the AccessWeb
     site
> as well.
>>>>Thanks in advance!
>>>Derek
>>>.
>>>>.
>>>.
>



Relevant Pages

  • RE: NT Authentication
    ... > HI derek, ... > 'username exists apply permissions ... > can be used to deny access to the database? ... >> strings to be used ...
    (microsoft.public.access.security)
  • RE: NT Authentication
    ... Dim dbs as Database ... 'username exists apply permissions ... > strings to be used ... (lpUserName, ...
    (microsoft.public.access.security)
  • Re: Startup Options - Im an idiot
    ... Derek ... Just point strDb to the name of your database. ... > varPropType, varPropValue) ... then I go back into the Startup routine ...
    (microsoft.public.access.modulesdaovba)
  • RE: NT Authentication
    ... Dim dbs as Database ... 'username exists apply permissions ... 'username does not exist deny permission ... (lpUserName, ...
    (microsoft.public.access.security)
  • Re: HELP! -- GETTING CLOSE
    ... website listing, then deleted the data database entries which marked them as ... Derek ... >> created a new configuration database and connected the Content Database ...
    (microsoft.public.sharepoint.portalserver)