Skip to content

Instantly share code, notes, and snippets.

@iversond
Created June 29, 2010 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iversond/457491 to your computer and use it in GitHub Desktop.
Save iversond/457491 to your computer and use it in GitHub Desktop.
Function DynamicSecurity()
Local string &URI, &Protocal, &ServerName, &LogFile, &External, &userID;
Local number &ProtocalLength, &ServerNameEnd, &ServerNameLength;
Local File &MyFile;
/* Get Login URI */
&URI = %Request.ContentURI;
/* Determine if SSL is used */
&Protocal = Substring(&URI, 0, 5);
If Lower(&Protocal) = "https" Then
&ProtocalLength = 9;
Else
&ProtocalLength = 8;
End-If;
/* Find server name from login URI */
&ServerNameEnd = Find("/", &URI, 10);
&ServerNameLength = &ServerNameEnd - &ProtocalLength;
&ServerName = Substring(&URI, &ProtocalLength, &ServerNameLength);
/* Check if the URI is for an external login */
SQLExec(SQL.RC_EXTERNAL_SERVER, &ServerName, &External);
&userID = Upper(%SignonUserId);
/* Update PSROLEUSER table based on internal/external security */
SQLExec(SQL.RC_DELETE_ROLEUSER, &userID);
If &External = "Y" Then
/* Insert external user roles from RC_ROLES table */
SQLExec(SQL.RC_INSERT_EXROLEUSER, &userID);
Else
/* Insert internal roles from RC_ROLEUSER table */
SQLExec(SQL.RC_INSERT_RCROLEUSER, &userID, &userID);
End-If;
/* Write Log File */
SQLExec(SQL.RC_SERVER_LOGGING, &ServerName, &LogFile);
If &LogFile = "Y" Then
&MyFile = GetFile("DynamicLogin.log", "A", %FilePath_Relative);
If &MyFile.IsOpen Then
&MyFile.WriteLine(%Datetime | " " | "URI: " | &URI | " " | "UserID: " | &userID);
&MyFile.WriteLine(%Datetime | " " | "ServerName: " | &ServerName | " " | "External: " | &External);
/*&MyFile.WriteLine(%Datetime | " " | "StartSubString: " | &ProtocalLength | " " | "Length: " | &ServerNameLength);*/
&MyFile.Close();
End-If;
End-If;
End-Function;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment