Custom Blackpearl User/Role Manager

Last post 02-05-2008, 11:26 AM by tbyrne. 4 replies.
Sort Posts: Previous Next
  •  01-14-2008, 12:09 PM 21083

    Custom Blackpearl User/Role Manager

    Has anyone attempted to use the API to create a custom user/role manager, kind of like this guy did for K2 2003: http://k2underground.com/forums/thread/14599.aspx?

    Is there any documentation out there for using the SecurityManagementAPI for blackpearl?  There is no reference to it in the SDK documentation...

    On the surface, it seems simple enough - it provides Add, Delete and Get methods for users and roles but I have a number of questions on how to actually use those methods.  For example, you need to provide either an 'Application' or 'Object' when getting a list of users or roles... what is an application or object in this context?


    Tim Byrne
    Clarity Consulting
    http://www.claritycon.com
  •  01-14-2008, 3:24 PM 21088 in reply to 21083

    Re: Custom Blackpearl User/Role Manager

    Well, I never found any documentation on the API, but once I found the CORRECT API, it became pretty straight-forward.  Here is a sample of some code for anyone else out there that may need to do something similar:

    // Instantiate the manager API

    UserRoleManager sm = new UserRoleManager();

     

    // Connect to environment

    sm.Connection = sm.CreateConnection();

    sm.Connection.Open("[host server connection string here, can get it from object browser]");

    // END connect to environment

    // List all roles

    Role[] roles = sm.GetRoles();

    foreach (Role role in roles)

    {

    System.Diagnostics.Debug.WriteLine(role.Name);

    System.Diagnostics.Debug.WriteLine("\t" + role.GetData());

    }

    // END list all roles

    // Add a new role

    Role newRole = new Role("Test");

    newRole.LoadData("<role name=\"Test\" guid=\"" + newRole.Guid + "\" description=\"\" isdynamic=\"false\"><include><users><user name=\"K2:BSD\\v-tbyrne\" /></users><groups /><smartobjects /></include><exclude><users /><groups /><smartobjects /></exclude></role>");

    sm.CreateRole(newRole);

    // END add new role

    // Append a '7' to the first role's description (update test)

    Role updateRole = roles[0];

    updateRole.Description += "7";

    sm.UpdateRole(updateRole);

    // END Append a '7' to the first role's description (update test)

     

    sm.Connection.Close();


    Tim Byrne
    Clarity Consulting
    http://www.claritycon.com
  •  01-15-2008, 12:12 AM 21095 in reply to 21088

    Re: Custom Blackpearl User/Role Manager

    Thanks for posting this Tim.  This should be helpful to many.
    The statements and opinions made in my postings are my own, and do not reflect the opinions of SourceCode Technology Holdings, Inc. or its subsidiaries. All information is provided as is with no warranties, express or implied, and grants no rights or licenses.
  •  02-04-2008, 8:44 PM 21676 in reply to 21088

    Re: Custom Blackpearl User/Role Manager

    What was the correct API?
  •  02-05-2008, 11:26 AM 21694 in reply to 21676

    Re: Custom Blackpearl User/Role Manager

    SourceCode.Security.UserRoleManager.Management

     


    Tim Byrne
    Clarity Consulting
    http://www.claritycon.com
View as RSS news feed in XML