August 28, 2009

AzMan Create/Remove Store with C#

I was looking through some old projects I did in AzMan as some are relevant to questions I received over the last few weeks. One person wanted to be able to create/remove a store through c#. This is easily done with the current API. I have uploaded a helper class here which has some comments not included in the short snippets below as well as simple checking for existing store. This class was designed to work with XML and AD (sorry not sql server yet).

Some examples:
public static IAzAuthorizationStore CreateStore(string storeUrl)
{
if (storeUrl == null || storeUrl.Length == 0)
{
throw new ArgumentNullException("storeUrl", "Store URL can not be null or empty.");
}

IAzAuthorizationStore store = new AzAuthorizationStoreClass();
store.Initialize(1, storeUrl, null);

store.Submit(0, null);

return store;
}

Here is how to remove that store:

public static void RemoveStore(string storeUrl)
{
if (storeUrl == null || storeUrl.Length == 0)
{
throw new ArgumentNullException("storeUrl", "Store URL can not be null or empty.");
}

IAzAuthorizationStore store = GetStore(storeUrl);

store.Delete(null);
}

No comments:

Post a Comment