Jump to content

Limit access to records by user


This topic is 6589 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I need to limit access to records by user by their Windows Logon Name. Essentially I want to copy their username out of the registry and paste it into a field in Filemaker. I know this can be done using a very simple VBScript, but I haven't been able to make it work. I would appreciate any help from a more talented scripter.

Link to comment
Share on other sites

I figured this one out. If anybody else would like to use it, this script pulls the username from the registry and creates a tab separated data file in the C drive that you can import data from - thereby logging who accessed your database.

Set wshell = WScript.CreateObject("Wscript.Shell")

Name2_CopyFromKey = "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon"

Name2_CopyFromValue = "DefaultUserName"

Name3_Key = "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon"

Name3_Value = "AltDefaultUserName"

Machine_Key = "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlComputerNameActiveComputerName"

Machine_Value = "ComputerName"

MachineName = wshell.RegRead (Machine_Key + Machine_Value)

UserName2Value = wshell.RegRead (Name2_CopyFromKey + Name2_CopyFromValue)

UserName3Value = wshell.RegRead (Name3_Key + Name3_Value)

'deletes user's temporary login file.

On Error Resume Next

Set fs = CreateObject("Scripting.FileSystemObject")

fs.DeleteFile("C:un.duf")

Dim FSO, AFile, AFileStream

Dim strSrcDir

' Set variables

strSrcDir = "c:"

' Set Objects

Set FSO = CreateObject("Scripting.FileSystemObject")

on error resume next

Set oFile=fso.GetFile("C:un.duf")

'Removes all file attributes, expecially read-only

oFile.Attributes = oFile.Attributes AND 0

If Err.Number = 0 Then

Set AFileStream = FSO.OpenTextFile(strSrcDir + "un.duf",2)

else

Set AFileStream = FSO.CreateTextFile(strSrcDir + "un.duf",2)

end if

' to enter quotes, either use double quotes, or the chr(34) character while chr(09) is tab.

AFileStream.WriteLine MachineName + chr(09) + UserName2Value + chr(09) + UserName3Value

Link to comment
Share on other sites

This topic is 6589 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.