Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise PowerShell Extensions Forum Unable to login to datasource with service account
    • Sign In

    • State Verified Answer
    • Replies 4 replies
    • Subscribers 66 subscribers
    • Views 865 views
    • Users 0 members are here
    • powershell
    • New-PWLogin

    Unable to login to datasource with service account

    Lachlan
    Offline Lachlan over 1 year ago

    Hi,

    I'm attempting to login to our datasource using a new service account, but receive an error 55501 when logging in.

    Currently this is what I'm using which results in the 55501 error:

    $userName = "username"
    $password = "password"
    $securePassword = $password | ConvertTo-SecureString -AsPlainText -Force
    
    New-PWLogin -DatasourceName 'server:datasource' -Username $userName -Password $securePassword

    I've had no issues whatsoever using -UseGui to login via IMS.

    Using -UseGui and manually entering the service account credentials results in "Error 50045 - Failed to get connection information. No database connection is active at the moment"

    What are some further troubleshooting steps to take? Has anybody faced a similar issue and found a workaround?

    Thanks all,

    Lachlan

    • Sign in to reply
    • Cancel

    Top Replies

    • Brian Flaherty
      Offline Brian Flaherty Wed, Apr 6 2022 5:13 PM +1 verified
      Your syntax is correct. Be sure you are passing the correct server and datasource values. Also, depending on the version of the PWE client, you may be required to be logged into the Bentley CONNECTION…
    • Brian Flaherty
      +1 Offline Brian Flaherty Wed, Apr 6 2022 5:13 PM

      Your syntax is correct. Be sure you are passing the correct server and datasource values. Also, depending on the version of the PWE client, you may be required to be logged into the Bentley CONNECTION client.

      Answer Verified By: Lachlan 

      • Cancel
      • Vote Up +1 Vote Down
      • Sign in to reply
      • Reject Answer
      • Cancel
    • Lachlan
      0 Offline Lachlan Wed, Apr 6 2022 9:10 PM in reply to Brian Flaherty

      Hi Brian,

      Thank you for the response.

      I think you might be on to something in terms of the server and datasource, because UseGui seems to fill the values from CONNECTION client, irrespective of the DatasourceName provided in the script and I've had no issues there. I'll ask around to make sure I've got the correct value for datasource

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Lachlan
      0 Offline Lachlan Thu, Apr 7 2022 1:53 AM

      Yep it turns out I was given an old datasource name, so the hardcoded name in the script wouldn't work. I assume IMS worked because it links directly into CONNECTION Client to get datasource names.

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Kevin van Haaren
      0 Offline Kevin van Haaren Fri, Apr 8 2022 10:50 PM in reply to Lachlan

      -UseGUI reads the ProjectWise datasources from the settings in ProjectWise network control panel (not from Connection Client), the GUI has a drop down of datasources and when you set that it uses the proper server info.

      You can see what datasources are available using the Get-PWDSConfigEntry:

      Get-PWDSConfigEntry | Sort Name | Select Name,FullName

      That will show the display name that appears in the GUI and the server:datasouce for it

      Also this:

      $userName = "username"
      $password = "password"
      $securePassword = $password | ConvertTo-SecureString -AsPlainText -Force

      Is a very bad idea. It completely subverts the reason for using secure strings to begin with. Now this script must be protected as securely as the password itself must be.

      The best security is to use single sign-on, Bentley IMS via connection client works great for this:

      New-PWLogin -DatasourceName 'server:datasource' -BentleyIMS
      

      That will log you in using the connection client with no GUI (assuming the server:datasource is correct...)

      If you absolutely need to login with a password, I recommend storing the secure string in an encrypted file using the PWPS_DAB function Save-SecureStringToEncryptedFile. You do this once, outside of your script, then you tell your script to get the secure string from the file:

      First (outside of the script):

      Save-SecureStringToEncryptedFile -FileName .\securestring.txt -prompt "enter password to encrypt and store"

      That creates a text file in the current directory named securesting.txt that contains an encrypted version of the password

      Then your script becomes:

      $secstr = Get-SecureStringFromEncryptedFile -FileName .\securestring.txt
      New-PWLogin -Datasource 'server:datasource' -Username 'username' -Password $secstr
      $secstr.Dispose()

      Additional benefit: if your password changes just re-run the Save-SecureStringToEncryptedFile again and update the encrypted password, then automatically every script that uses it is updated with the new password.

      (the $secstr.Dispose() is there to make sure the unencrypted form of the password is wiped from memory as soon as you're done using it)

       

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel

    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2023 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies