UserGetMemberInfo Method (ConnectionId, SessionId, Int32) Content Studio 5.7 SDK
Content Studio Web Content Management System

[This is preliminary documentation and is subject to change.]

Returns the registered groups where the user is a member.

Namespace: ContentStudio.Security
Assembly: CSServer5 (in CSServer5.dll) Version: 5.7.5016.0 (5.7.5016.0)
Syntax

public override string GetMemberInfo(
	ConnectionId connectionId,
	SessionId sessionId,
	int userId
)

Parameters

connectionId
Type: ContentStudioConnectionId
A value that identifies the web site
sessionId
Type: ContentStudio.SecuritySessionId
A value that identifies the user's session. This value usually originates from a call to OpenSession(ConnectionId).
userId
Type: SystemInt32
An identifier to a trustee object to examine. This parameter can be zero to examine the caller's own group memberships.

Return Value

Type: String
Xml
<root>
    <status>0</status>
    <statustext>Success</statustext>
    <objects>
        <object>
            <id>123</id>
            <type>LocalGroup</type>
            <name>MyGroup</name>
            <domain>MyDomain</domain>
            <fullname>MyGroup</fullname>
        </object>
        <!-- more object nodes, representing more groups, can follow-->
    </objects>
</root>
Exceptions

ExceptionCondition
CSExceptionA business rule was violated in the underlying Content Studio database
CSPermissionDeniedExceptionThe caller has no permission to perform the requested action
CSInvalidSessionExceptionThe session is invalid
CSInvalidParameterExceptionA parameter has an invalid value
SqlExceptionAn error occurred when executing the command against the Content Studio database
Content Studio permissions

Execute permission is permitted to all authenticated users.
Remarks

The list of groups is renewed every time a user opens a new session against Content Studio. This list consists of all groups registered in Content Studio that the user has in her access token when native Windows authentication is used, or any registered group that a custom authentication provider has determined that the caller is a member of.
Examples

The following code shows how to get the name of each registered group where the calling user is a member. The code is designed to run on a Content Studio web page.

First add an Asp Literal control on a new empty Content Studio page

Html
<div>
<asp:Literal id="Literal1" runat="server"/>
</div>

Then, if not already present, create an event handler in code behind that handles the Load event of the page and add the following code to this event handler.

protected void Page_Load(object sender, System.EventArgs e)
{
    ContentStudio.Security.User user = 
        new ContentStudio.Security.User();
    System.Collections.Generic.List<string> listOfGroups = 
        new System.Collections.Generic.List<string>();
    using(System.IO.StringReader reader = 
        new System.IO.StringReader(user.GetMemberInfo(CS_ConnectionId, CS_UserSessionId, 0)))
    {
        using(XmlReader xReader = XmlReader.Create(reader))
        {
            while(xReader.ReadToFollowing("object"))
            {
                string name = null;
                string domain = null;
                while (xReader.Read())
                {
                    if (xReader.NodeType == XmlNodeType.Element)
                    {
                        if (xReader.Name == "domain")
                            domain = xReader.ReadString();
                        if (xReader.Name == "name")
                            name = xReader.ReadString();
                    }
                    else if (xReader.NodeType == XmlNodeType.EndElement && xReader.Name == "object")
                        break;
                }
                if (name != null)
                    listOfGroups.Add(String.Format(@"{0}\{1}", domain, name));
            }
        }
    }
    StringBuilder sbu = new StringBuilder();
    sbu.AppendLine("<ul>");
    foreach(string groupName in listOfGroups)
    {
       sbu.AppendLine(String.Format("<li>{0}</li>", groupName));
    }
    sbu.AppendLine("</ul>");
    Literal1.Text = sbu.ToString();
}

A bulleted list of group names should be visible when you preview the page.

See Also

Reference