September 12, 2009

What's new in Powershell V2.0

Nice slideshow on this!

September 11, 2009

Using the AzMan Helper Classes

We have seen how to add a store,create an application, add an operation, add tasks, create roles, add application groups, and add users via SID or UPN to groups in AzMan using C#. All of these are available here. The question is, how do I use those classes. I will show below some practical uses:
public void AddStore(string storeUrl)
{
StoreHelper.CreateStore(storeUrl);
}

public void RemoveStore(string storeUrl)
{
StoreHelper.RemoveStore(storeUrl);
}

public bool IsStoreExists(string storeUrl)
{
return StoreHelper.IsStoreExists(storeUrl);
}

//Get list of application names
public string[] GetApplications(string storeUrl)
{
IAzAuthorizationStore store = StoreHelper.GetStore(storeUrl);
return ApplicationHelper.GetApplicationNames(store);
}

public void AddApplication(string storeUrl, string applicationName)
{
IAzAuthorizationStore store = StoreHelper.GetStore(storeUrl);
ApplicationHelper.AddApplication(store, applicationName);
}

public void RemoveApplication(string storeUrl, string applicationName)
{
IAzAuthorizationStore store = StoreHelper.GetStore(storeUrl);
ApplicationHelper.RemoveApplication(store, applicationName);
}

public bool IsApplicationExists(string storeUrl, string applicationName)
{
IAzAuthorizationStore store = StoreHelper.GetStore(storeUrl);
return ApplicationHelper.IsApplicationExists(store, applicationName);
}

Here are some very, very, very basic uses of the helper classes. I'll add a few more simple uses over the next day or so.

September 10, 2009

AzMan Add/Remove Members to Role by SID or UPN with C#

We have already seen how to add a store,create an application, add an operation, add tasks, create roles, and add application groups in AzMan using C#. Now, let's go on to adding users by name or SID to those roles using c#. I have uploaded a helper class here which has some comments not included in the short snippets below as well as some other methods (check if exists etc.). This class was designed to work with XML and AD (sorry not sql server yet).

One of the cool things is that you can add a member to a role by a SID. This though has to be done via code. Below you can find how to ao a bunch of this via SIDs...the helper class shows how you can do the same thing with UPN as well:
 public static void AddRoleMember(IAzRole role, string memberSID)
{
if (memberSID == null || memberSID.Length == 0)
{
throw new ArgumentNullException("memberSID", "Member SID can not be null or empty.");
}
if (role == null)
{
throw new ArgumentNullException("role", "Role can not be null.");
}

role.AddMember(memberSID, null);
role.Submit(0, null);
}
Now let's remove that member by SID from the role
 public static void RemoveRoleMember(IAzRole role, string memberSID)
{
if (memberSID == null || memberSID.Length == 0)
{
throw new ArgumentNullException("memberSID", "Member SID can not be null or empty.");
}
if (role == null)
{
throw new ArgumentNullException("role", "Role can not be null.");
}

role.DeleteMember(memberSID, null);
role.Submit(0, null);
}
How about returning true if role member SID exists?
 public static bool IsRoleMemberExists(IAzRole role, string memberSID)
{
if (memberSID == null || memberSID.Length == 0)
{
throw new ArgumentNullException("memberSID", "Member SID can not be null or empty.");
}

if (role == null)
{
throw new ArgumentNullException("role", "Role can not be null.");
}

foreach (string sid in GetRoleMemberNames(role))
{
if (String.Compare(memberSID, sid) == 0)
{
return true;
}
}

return false;
}

September 9, 2009

AzMan Create/Remove/Get SIDs or UPN ApplicationGroup with C#

We have already seen how to add a store,create an application, add an operation, add tasks, and create roles in AzMan using C#. Now, let's go on to creating an application group within AzMan as well as get the group member names and the group members by their SIDs or UPN using c#. I have uploaded a helper class here which has some comments not included in the short snippets below as well as some other methods (check if exists etc.). This class was designed to work with XML and AD (sorry not sql server yet).
 public static IAzApplicationGroup AddApplicationGroup(IAzApplication app, string applicationGroupName)
{
if (applicationGroupName == null || applicationGroupName.Length == 0)
{
throw new ArgumentNullException("applicationGroupName", "ApplicationGroup name can not be null or empty.");
}
if (app == null)
{
throw new ArgumentNullException("app", "Application can not be null.");
}

IAzApplicationGroup applicationGroup = app.CreateApplicationGroup(applicationGroupName, null);

applicationGroup.Submit(0, null);

return applicationGroup;
}
Now let's remove that group:
 public static void RemoveApplicationGroup(IAzApplication app, string applicationGroupName)
{
if (applicationGroupName == null || applicationGroupName.Length == 0)
{
throw new ArgumentNullException("applicationGroupName", "ApplicationGroup name can not be null or empty.");
}
if (app == null)
{
throw new ArgumentNullException("app", "Application can not be null.");
}

app.DeleteApplicationGroup(applicationGroupName , null);

app.Submit(0, null);
}
We need to get by the SID as well:
public static string[] GetApplicationGroupMembers(IAzApplicationGroup applicationGroup)
{
if (applicationGroup == null)
{
throw new ArgumentNullException("applicationGroup", "Application group can not be null.");
}

Array sourceApplicationGroupMembers = (Array)applicationGroup.Members;
string[] applicationGroupMembers = new string[sourceApplicationGroupMembers.Length];
sourceApplicationGroupMembers.CopyTo(applicationGroupMembers, 0);
return applicationGroupMembers;
}
Check the actual helper class on how to get the user based off UPN as well as a few other methods.

September 8, 2009

AzMan Create/Remove/Get Role with C#

We have already seen how to add a store,create an application, add an operation, and create tasks in AzMan using C#. Now, let's go on to creating a role using c#. I have uploaded a helper class here which has some comments not included in the short snippets below as well as some other methods (check if exists etc.). This class was designed to work with XML and AD (sorry not sql server yet).
public static IAzRole AddRole(IAzApplication app, string roleName)
{
if (roleName == null || roleName.Length == 0)
{
throw new ArgumentNullException("roleName", "Role name can not be null or empty.");
}
if (app == null)
{
throw new ArgumentNullException("app", "Application can not be null.");
}

IAzRole role = app.CreateRole(roleName, null);

role.Submit(0, null);

return role;
}
Now let's remove that role:
public static void RemoveRole(IAzApplication app, string roleName)
{
if (roleName == null || roleName.Length == 0)
{
throw new ArgumentNullException("roleName", "Role name can not be null or empty.");
}
if (app == null)
{
throw new ArgumentNullException("app", "Application can not be null.");
}

app.DeleteRole(roleName , null);

app.Submit(0, null);
}
Get role by name:
 public static IAzRole GetRole(IAzApplication app, string roleName)
{
if (roleName == null || roleName.Length == 0)
{
throw new ArgumentNullException("roleName", "Role name can not be null or empty.");
}
if (app == null)
{
throw new ArgumentNullException("app", "Application can not be null.");
}

return app.OpenRole(roleName, null);
}

September 7, 2009

Vacation Day

Taking the day off to spend with family. Some interest was sparked with my AzMan posts in the last week, so I will continue with that tomorrow.

September 6, 2009

Up Bright and Early

Time for a nice long run!