Access and Windows login (AD)

S

SF

Hi,

I was assign to develop an Admin Forms database for my office. It consists
of 20 or more form. Our HR personel adviced us not to allow browsing staff
information. Is there a way to capture login name of the current user from
AD? I want to bing this login name to the name of staff sothat staff who
uses the form can only select their own name (I want to restirct this
because if user can browse other staff name he/she can see the remaining
balance of the medical allowance, education of the other.).

TIA

SF
 
P

pietlinden

Hi,

I was assign to develop an Admin Forms database for my office. It consists
of 20 or more form. Our HR personel adviced us not to allow browsing staff
information. Is there a way to capture login name of the current user from
AD? I want to bing this login name to the name of staff sothat staff who
uses the form can only select their own name (I want to restirct this
because if user can browse other staff name he/she can see the remaining
balance of the medical allowance, education of the other.).

TIA

SF

this does it. You can filter the form in the open event to filter for
the user's NT Login ID.
http://www.mvps.org/access/api/api0008.htm
 
P

Pete D.

If security is that important then you need to move to SQL database. But if
your on a budget use access as a index to other files. Store file names and
keep the data outside of access in individual password protected documents.
But to answer your question
http://www.mvps.org/access/api/api0008.htm
will get you the logon name.
 
S

SF

Hi Chris,

Thank you for your advice.

My FE is connected to SQLServer 2005 back end. I modify my table to add a
column 'Owner' and assigh SUSER_SNAME() as default value. I found that
SUSER_SNAME() return Domain\Username which does not match value provided by
fOSUserName() which return only username.

How to store only username in the Owner column?

SF
 
S

SF

Thank you. I will try my best.

SF

Chris O'C via AccessMonster.com said:
Technically, domain\username is correct, since Regents\JohnSmith and
Staff\
JohnSmith may not be the same user. But I think you don't want to see the
domain name in your table because everyone is on the same domain, so it's
redundant.

You have several alternatives. You could write a select query that uses
vba
to only show the username, even though the domain name is stored in the
table
with the username. This is probably the easiest.

If you want to keep SUSER_SNAME() as the default value, you could write a
trigger in Transact sql to fix it after the row is created. You could
write
a stored procedure in Sql Server or a query in Access to update the column
so
it removes the domain name in a specific row or in every row. You could
write a vba procedure in Access to update the column.

Or you could skip having SUSER_SNAME() as the default value. Write a vba
procedure that inserts the value of fOSUserName when the record is
created.
Probably the form's after insert event would be best.

Chris
Microsoft MVP

Hi Chris,

Thank you for your advice.

My FE is connected to SQLServer 2005 back end. I modify my table to add a
column 'Owner' and assigh SUSER_SNAME() as default value. I found that
SUSER_SNAME() return Domain\Username which does not match value provided
by
fOSUserName() which return only username.

How to store only username in the Owner column?

SF
The code here will get the user's windows name:
[quoted text clipped - 21 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top