Extract detailed user info with business rule

JohannJ
New Contributor

Hi,

For user maintenance purposes we'd like to extract information like user email address etc, using business rules.

I've tried using BRApi.Security.Admin.* but that only seems to support extracting a few of the fields, like name, status and text fields.

If anyone has any ideas or suggestions on how to accomplish this, it'd be greatly appreciated if you'd share.

Have a good one,

Johann

1 ACCEPTED SOLUTION

Krishna
Valued Contributor

@JohannJ  - 

 

BR

Dim objGroupInfo As GroupInfo = BRApi.Security.Admin.GetGroup(si, secGroupName)

Dim objUserInfo As UserInfo = BRApi.Security.Admin.GetUser(si, userName)


SQL

SELECT S.UniqueID as UserID , S.Name as Username, G.Name As GroupName
FROM SECUSER S JOIN SECGROUPCHILD SG
ON S.UniqueID = SG.CHILDKEY
JOIN SECGROUP G
ON SG.GROUPKEY = G.UniqueID

Thanks
Krishna

View solution in original post

3 REPLIES 3

MarcusH
Contributor III

You need to have a look at Methods. They are canned SQL statements that retrieve a load of really useful information. For the user email address you want to use the method Users:

Using ds As DataSet = BRApi.Database.ExecuteMethodCommand(dbConnFW, XFCommandMethodTypeId.Users, "{}", "UserList", Nothing)
    If Not ds Is Nothing Then
        If ds.Tables.Count > 0 Then
            Dim dt As DataTable = ds.Tables("UserList").Copy
            For Each dr As DataRow In dt.Rows()
                Dim UserName As String = dr("UserName")
                Dim UserEmail As String = dr("Email")
            Next
        End If
    End If
End Using

That will give you the user name and their email address plus other data. To get more information on Methods and the data they provide, create a test Maintenance Unit and then create a Data Adapter, select Method as the Command Type. Method Type then populates a list of the available methods:

MarcusH_0-1714051796255.png

Run that method and it shows the output with the column headers that you can then reference in a Business Rule.

 

You can also extract name and email (and other properties) using this BRApi to retrieve the UserInfo object.

Search GetUser in the BR snippets library

' Create stringbuilder		
Dim sb As New Text.StringBuilder()		

' Get User
Dim objUserInfo As UserInfo = BRApi.Security.Admin.GetUser(si, si.UserName)
' Get UserName
sb.AppendLine(String.Format("UserName > {0}", objUserInfo.User.Name))
'Get UserEmail
sb.AppendLine(String.Format("UserEmail > {0}", objUserInfo.User.Email))

' Log Result -> Throw Error				
Throw New XFException(Convert.ToString(sb))		

 

Krishna
Valued Contributor

@JohannJ  - 

 

BR

Dim objGroupInfo As GroupInfo = BRApi.Security.Admin.GetGroup(si, secGroupName)

Dim objUserInfo As UserInfo = BRApi.Security.Admin.GetUser(si, userName)


SQL

SELECT S.UniqueID as UserID , S.Name as Username, G.Name As GroupName
FROM SECUSER S JOIN SECGROUPCHILD SG
ON S.UniqueID = SG.CHILDKEY
JOIN SECGROUP G
ON SG.GROUPKEY = G.UniqueID

Thanks
Krishna