Adding multiple web controls on the same line in ASP.Net Mobile forms

When developing ASP.NET mobile forms, by default, each control is added on a single line. However, you can still add multiple controls on the same line by setting the  BreakAfter property to false of the control you want to add a control after and appear on the same line. This property is set by default to true and it is advisable to keep as it is and display only one control per line in order to maintain a linear behavior.

How to view the members of addresslist created by Exchange Management Shell

The exchange management console supports you to view the members or resources of an addresslist. However, you can get only members/resources of addresslists created by the exchange  management console. In order to view members/resources of addresslists created by the exchange management shell you have to use the exchange management shell commands. You will have to run two consecutive commands in order to obtain the members of the addresslist.

First you have to run the get-addresslist command to get the full path of the address list.

Get-AddressList -Identity "addresslist name" | fl DistinguishedName

For example, Get-AddressList -Identity "mylist" | fl DistinguishedName will return something like that CN=mylist,CN=All Address Lists,CN=Address Lists Container,CN=EDUProducts Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=eduproducts,DC=dev

Second you will use the returned string to run the following command:

Get-Recipient -Filter {AddressListMembership -eq ‘CN=mylist,CN=All Address Lists,CN=Address Lists Container,CN=EDUProducts Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=eduproducts,DC=dev’ 

Note: only users that have mailboxes created will appear. Users with no mail boxes will not be returned.

For further information about exchange shell commands:

http://technet.microsoft.com/en-us/library/bb430757(EXCHG.80).aspx

How to get all users Active Directory Schema properties

I encountered a problem where I wanted to retrieve all the active directory user’s attributes, configured and not configured, in a Hashtable and a flag whether the attribute is multivalue or not. I tried first

DirectoryEntry _entry = new DirectoryEntry(path);
return _entry.Properties;

The problem with that is that it returns only the configured attributes. After searching for a while I reached that solution which returns all the attributes for an active directory entry, configured and not configured.

public static Hashtable GetADSchemaProperties()
{
   //connect to AD and get the current schema.
   ActiveDirectorySchema schema = ActiveDirectorySchema.GetCurrentSchema();
   DirectoryEntry user = null;
   try
   {
     //get the current username
     WindowsIdentity currentIdentity = WindowsIdentity.GetCurrent();
     WindowsPrincipal currentPrincipal = new WindowsPrincipal(currentIdentity);
     string userName = currentPrincipal.Identity.Name;
     userName = userName.Split(new char[] { '\\' })[1];

        //get the current user
        DirectoryEntry user = GetADEntryUser(userName);

        ArrayList properties = FindUserProperties(user);
        if (properties == null || properties.Count == 0)
            return null;

       //Add values to Hashtable.
       Hashtable propertiesList = new Hashtable();
       foreach (string propertyName in properties)
               propertiesList.Add(propertyName, !schema.FindPropert(propertyName).IsSingleValued);
       return propertiesList;
}
catch (Exception ex)
{
    Logging.GetInstance().LogException(ex);
    return null;
}
finally
{
    //Dispose all objects
    if(user != null)
        user.Dispose();
    if(schema != null)
        schema.Dispose();
}
}

private static ArrayList FindUserProperties(DirectoryEntry user)
{
   string ldapPath = user.LDAPPath.ToString();
   DirectoryEntry directoryEntry = new DirectoryEntry(ldapPath);
   directoryEntry.AuthenticationType = 
   AuthenticationTypes.Secure|AuthenticationTypes.ServerBind | AuthenticationTypes.Sealing;
   object o = directoryEntry.NativeObject;

   DirectorySearcher mySearcher = new DirectorySearcher(directoryEntry);
   mySearcher.Filter = (“(objectClass=user)”);
   mySearcher.PropertyNamesOnly = true;
   mySearcher.PropertiesToLoad.Clear();

   SearchResult searchRes = mySearcher.FindOne();
   if (searchRes == null)
      return new ArrayList();

   DirectoryEntry schemaEntry = new DirectoryEntry((searchRes.GetDirectoryEntry().SchemaEntry.Path));

   //NOTE: One place where managed ADSI (System.DirectoryServices) falls short is finding schema
   //information from LDAP/AD objects. Finding information like mandatory and optional
   //properties simply cannot be done with any managed classes

   IADsClass iadsClass = (IADsClass)schemaEntry.NativeObject;
   if (iadsClass == null)
   return new ArrayList();

   ArrayList list = new ArrayList();
   foreach (string s in (Array)iadsClass.OptionalProperties)
   {
       list.Add(s);
   }
   foreach (string s in (Array)iadsClass.MandatoryProperties)
   {
      list.Add(s);
   }
   return list;
}