AR-k12code / CognosDownloader

MIT License
2 stars 3 forks source link

FMS cognos download issues #21

Closed benjanelle closed 3 years ago

benjanelle commented 3 years ago

-username parameter is currently required (in addition to the -efpuser paramenter) to authenticate on FMS Cognos.

CAMID on FMS side only wants the name portion of the login (no lea) ex: bjanelle instead of 5805bjanelle. Suggested fix for the fms block:

If ($eFinance) { $camName = "efp" #efp for eFinance $dsnparam = "spi_db_name" $dsnname = $efpdsn $efpuser = $efpuser -replace '[^a-zA-Z-]','' #strip the numbers out of the username for the CAMID string $camid = "CAMID(""efp_x003Aa_x003A$($efpuser)"")" }

VBSDbjohnson commented 3 years ago

The eFinance username may not just be the non-number part of the SSO login. This may not work in all cases. Better to at least throw an error when both are not specified with the -eFinance switch

benjanelle commented 3 years ago

My login is 5805bjanelle, which is required for authentication, but whatever the CAMID stuff is only wants bjanelle. Might need 2 variables? I've only messed with my account, so I'm sure there are other use cases that could differ.

VBSDbjohnson commented 3 years ago

There already is two variables -username and -efpuser Some of the original APSCN FMS folks in our district had their original username (less than 8 characters) when the initial changeover to eFinance happened. Also, a SSO account that was created automatically as 1705brjohnson (because of duplication handling for SSO accounts) may be the first to use eFinance and is assigned bjohnson instead of their SSO variation of brjohnson. Unless they do some conversion and restrictions on how the eFinance administrators add accounts/security rights, it may have to stay that way. The SSO authentication still uses the -username account, then it authenticates using the -efpuser (which could be different)

benjanelle commented 3 years ago

Makes sense, and is why you guys run these projects and not me :)

I think mine is a transfer from the old Unix systems too, so that makes sense why it doesn't match. I suppose my only suggestion is to not call out the -username parameter as "eSchool SSO username," since it's needed for both versions, and maybe add an FMS Cognos usage example that shows they might differ.

VBSDbjohnson commented 3 years ago

Perhaps your code could still be used but implement an override in case the efpuser is different.

If ($eFinance) {
    $camName = "efp"    #efp for eFinance
    $dsnparam = "spi_db_name"
    $dsnname = $efpdsn
    #switch efpuser can be used to override this eFinance user assumption
    If (-not $efpuser) { $efpuser = $username -replace '[^a-zA-Z-]','' } #strip the numbers out of the username for the CAMID string
    $camid = "CAMID(""efp_x003Aa_x003A$($efpuser)"")"
} else {
    $camName = "esp"    #esp for eSchool
    $dsnparam = "dsn"
    $dsnname = $espdsn
    $camid = "CAMID(""esp_x003Aa_x003A$($username)"")"
}
VBSDbjohnson commented 3 years ago

Apparently my logic has failed. Either need to remove the default value of $efpuser in the parameters: [string]$efpuser, #YOU SHOULD NOT MODIFY THIS. USE THE PARAMETER. FOR BACKWARDS COMPATIBILTY IT IS NOT REQUIRED BUT SHOULD BE IN THE FUTURE. CONSIDER USING THE CognosDefaults.ps1 OVERRIDES. Or change the if override if statement to If (-not $efpuser -or $efpuser -eq "yourefinanceusername") { $efpuser = $username -replace '[^a-zA-Z-]','' } #strip the numbers out of the username for the CAMID string IMHO: it is better to not have default values that could break functionality

carbm1 commented 3 years ago

I have limited access to eFinance. As in POs only. I had no idea this is why the reports in the My Content folder were failing. The response from the Cognos server directs me into 0403cmillsap but it is really just cmillsap. Which now works for me using the -efpuser cmillsap.

Working command line with the current script non-modified: . .\CognosDownload.ps1 -username 0403cmillsap -efpuser cmillsap -efpdsn gentryfms -eFinance -report openpos -savepath . -Verbose -ShowReportDetails

The -username 0403cmillsap authenticates with the SSO credentials. This allows reports from the Shared Content folders. The -efpuser cmillsap gives me access to My Content. Is this True for everyone though? Do new accounts need the numbers stripped from it?

VBSDbjohnson commented 3 years ago

I don't believe that every user will match that pattern. It may be something that has transitioned to that way, but originally users were migrated from the old APSCN FMS shell/text system. That's why I think it could be defaulted as the username without the numbers, but allow an override to work by specifying the -efpuser switch. I may try to get my environment back up and do a little coding myself. It returns this error when the report can't be found with the incorrect username: Unable to retrieve report details. Please check the supplied report name and cognosfolder. RDS-ERR-1012 Report Data Service was unable to discover the content providers.

Cweber-RPS commented 3 years ago

We have the ability in the default and commandline to sepcify the EPFuser, I run a switch in my default's that will auto switch the EPFusername based off the SSO username. I would highly recommend that for everyone, that way you don't have to worry about mistyping on the commandline or anywhere else.

benjanelle commented 3 years ago

I don't guess there's anything keeping from pulling their "real" efp username from one of the server responses, but as written it works as long are you call out the -username and differentiated -efpuser. My initial issue was this failed (couldn't authenticate):

CognosDownloader.ps1 -efpuser bjanelle -efpdsn russellvfms -eFinance -report Apptegy_Staff -savepath C:\ImportFiles\Apptegy\ -passwordfile C:\Scripts\BENapscnpw.txt

Then this failed with "check the supplied report name..."

CognosDownloader.ps1 -username 5805bjanelle -efpuser 5805bjanelle -efpdsn russellvfms -eFinance -report Apptegy_Staff -savepath C:\ImportFiles\Apptegy\ -passwordfile C:\Scripts\BENapscnpw.txt

It took me longer than it probably should've to see that -username is needed for both SMS and FMS cognos, and that my FMS login differed. If it's just me being dumb, don't feel the need to change anything on my behalf :)

Cweber-RPS commented 3 years ago

Ben check out the CognosDefaults.ps1 it will help save you a TON of typing, and to keep it working in a multi-user environemnt don't specify a default -username, but configure the switch for each username(s) and the password file(s) for them, that way when you call it you can make it be:

CognosDownloader.ps1 -username 5805bjanelle -eFinance -report Apptegy_Staff -savepath C:\ImportFiles\Apptegy\

These would be specified in the switch on your CognosDefaults: -efpuser 5805bjanelle -efpdsn russellvfms -passwordfile c:\scripts\benpw.txt (example)

benjanelle commented 3 years ago

I already have 30+ batch files with how I already did it. Maybe next round!