Binnys Respected Contributor.
Respected Contributor.
456 views

Unable to login_After removing group from user through OTA script

Hi,

I'm using below script to remove 'Viewer' group for the QC user which is newly created from QC admin site. In our project when user is created from site admin then 'Viewer' group is added by default. 

The issue that i'm facing that, the new user couldn't able to login with his credentials, though the below script is working fine as it is successfully removing the 'Viewer' group for user. (or i can say removing user from 'Viewer' group)

When the new user is trying to loging in QC(version10.00), then his is getting a message as "All Licences are currently in use"

 

Sub DEL_USER_GROUP()

Dim QcConnection As Object
Dim Qcurl As String
Dim QcUser As String
Dim QcPass As String
Dim QcDomain As String
Dim QcProject As String

Qcurl = Sheets("Variables").Cells(10, 2).Value

QcUser = Sheets("Variables").Cells(13, 2).Value

QcPass = Sheets("Variables").QCAdmin_Password_TextBox.Value

QcDomain = Sheets("Variables").Cells(11, 2).Value

QcProject = Sheets("Variables").Cells(12, 2).Value


'Making QC connection and login

Set QcConnection = CreateObject("TDApiOle80.TDConnection.1")

QcConnection.InitConnectionEx Qcurl

QcConnection.Login QcUser, QcPass

QcConnection.Connect QcDomain, QcProject

If (QcConnection.Connected <> True) Then
ConnectToQC = False
Else
ConnectToQC = True
End If


'Dim Cust As Customization
Dim Custusers
Dim CustUsersGroups
Dim CustGroup
Dim NewUser As String
Dim NewGroup As String

Set Cust = QcConnection.Customization

Cust.Load

Set Custusers = Cust.Users.User("newuserid")
Custusers.RemoveFromGroup ("Viewer")
Cust.Commit

QcConnection.Disconnect
QcConnection.Logout
QcConnection.ReleaseConnection
Set QcConnection = Nothing


End Sub

 

Please sugguest.

 

Thanks

Binny

0 Likes
10 Replies
Binnys Respected Contributor.
Respected Contributor.

Re: Unable to login_After removing group from user through OTA script

Hi,

It's been 4 days since i poseted this query, Can i have an expert advise on this ?

 

 

Thanks

Vineet

0 Likes
NEW_ALM12 Outstanding Contributor.
Outstanding Contributor.

Re: Unable to login_After removing group from user through OTA script

Is it ALM10.00?

Few points to understand your env:

1) Is any user that is not removed from Viewer group from the Project getting same error when logged into the project?

2) Did you check licnese usages when the user that s removed from viewer got the error?

3) Was license usage full or not?

4) Is "User Quota" setup as "Unlimited connections in the same project where user was removed? 

0 Likes
Chris_Grz Outstanding Contributor.
Outstanding Contributor.

Re: Unable to login_After removing group from user through OTA script

If I remember well, every new user is added by default to the Viewer group and only to that group. That means that your new users are not assigned to any group and may explain why they cannot login. The error message does not seem explicit though.
Binnys Respected Contributor.
Respected Contributor.

Re: Unable to login_After removing group from user through OTA script

Please see my response below:-

It is QC(10.00) not ALM 10.00

 

1) Is any user that is not removed from Viewer group from the Project getting same error when logged into the project?  Binny:- No, if the user is not removed from the group (Viewer Group) then, he can login successfully.

2) Did you check licnese usages when the user that s removed from viewer got the error? Binny:- The licence usage was well below the maximum limit allowed at the time when new user was removed from 'Viewer' group and he tried to login.

3) Was license usage full or not?  Binny:- Licence usage was not full.

4) Is "User Quota" setup as "Unlimited connections in the same project where user was removed?  Binny:-Yes

 

 

0 Likes
Binnys Respected Contributor.
Respected Contributor.

Re: Unable to login_After removing group from user through OTA script

Before i run this script to remove the user from viewer group, i'm adding the new user from Site Admin and assiging him to a new group(Say group 'Devlopers') and user is getting added to that group + Viewer group by default.

 

Then i'm running this script to remove user from viewer group but letting him in the another group(Devlopers group) and then login activity is getting failed.

 

If i manually remove the user from Viewer group and save the information under customization section, then everything works normally and user is able to login without any licence error.

0 Likes
NEW_ALM12 Outstanding Contributor.
Outstanding Contributor.

Re: Unable to login_After removing group from user through OTA script

Not sure whats wrong on your side. But, I modified/added two lines as below and I do not see any error to login by the user. 

I would suggest to edit your code by below lines of code and test it. 

Set Custusers = cust.Users.user("tmp123")
If Custusers.InGroup("Viewer") Then
Custusers.RemoveFromGroup ("Viewer")
cust.Commit
End If
Next
Binnys Respected Contributor.
Respected Contributor.

Re: Unable to login_After removing group from user through OTA script

Hello, 

First of all, is that 'Next' in your code is typo from your side ?,, because that 'Next' is wihout 'For'

 I modified my code by the lines of codes that you suggested below (wihtout 'Next' though) and it did NOT work.

I'm still getting the 'Licence' error on login, though the group 'Viewer' was successfully removed for user.

 

 

Thanks for replying...

0 Likes
Highlighted
NEW_ALM12 Outstanding Contributor.
Outstanding Contributor.

Re: Unable to login_After removing group from user through OTA script

Interesting your code work for me and not for yourself.

Regrading "Next", its not a typo. But instead it was an enhancement and additional code in the script. You have Single user removing from Viewer group. But, I have group of users that I would have to remmove users from Viewer group. So, I put the user list in excel's one of the row and remove them from viewer group. Hence, I was doing as below: 

rCount = Sheets("User Create_Add to ALM project").UsedRange.Rows.Count
For i = 3 To rCount

Dim Custusers
Dim CustUsersGroups
Dim CustGroup
Dim NewUser As String
Dim NewGroup As String
Dim UserName

UserName = Sheets("User Create_Add to ALM project").Range("A" & i).Value
Set cust = QcConnection.Customization
cust.Load
Set Custusers = cust.Users.user(UserName)
If Custusers.InGroup("Viewer") Then
Custusers.RemoveFromGroup ("Viewer")
cust.Commit
End If
Next

This works perfect for me.

Im creating user/s using create function, adding them to project using Addtoproject function and now removing them fromviewer group using Removefromgroup function. And users list is in my excel sheet. All functions are working perfectly. 

Good luck!

Binnys Respected Contributor.
Respected Contributor.

Re: Unable to login_After removing group from user through OTA script

Which version of QC you are using ?

are you creating the qc object like below ?

Set QcConnection = CreateObject("TDApiOle80.TDConnection.1")

Would you paste your entire code from starting till end where are objects are released and QC connection is disconnected ?

0 Likes
NEW_ALM12 Outstanding Contributor.
Outstanding Contributor.

Re: Unable to login_After removing group from user through OTA script

I tested your code in ALM11.00. Worked fine. 

Yes, I have created object as below.

Set QcConnection = CreateObject("TDApiOle80.TDConnection.1")

Code - Its your code replica.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.