Skip to main content

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?

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


Rolel] roles = sm.GetRoles();


foreach (Role role in roles)


{


System.Diagnostics.

Debug.WriteLine(role.Name);


System.Diagnostics.

Debug.WriteLine(" " + 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:BSDv-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 = rolese0];


updateRole.Description +=

"7";


sm.UpdateRole(updateRole);


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


 


sm.Connection.Close();


Thanks for posting this Tim.  This should be helpful to many.
What was the correct API?

SourceCode.Security.UserRoleManager.Management


 


Reply