Esempio n. 1
0
        //
        // Splits up a DN into it's components
        // e.g. cn=a,cn=b,dc=c,dc=d would be returned as 
        // a component array
        // components[0].name = cn
        // components[0].value = a
        // components[1].name = cn
        // components[1].value = b ... and so on
        // 
        internal static Component[] GetDNComponents(string distinguishedName)
        {
            Debug.Assert(distinguishedName != null, "Utils.GetDNComponents: distinguishedName is null");

            // First split by ','
            string[] components = Split(distinguishedName, ',');
            Component[] dnComponents = new Component[components.GetLength(0)];

            for (int i = 0; i < components.GetLength(0); i++)
            {
                // split each component by '='
                string[] subComponents = Split(components[i], '=');
                if (subComponents.GetLength(0) != 2)
                {
                    throw new ArgumentException(Res.GetString(Res.InvalidDNFormat), "distinguishedName");
                }

                dnComponents[i].Name = subComponents[0].Trim();
                if (dnComponents[i].Name.Length == 0)
                {
                    throw new ArgumentException(Res.GetString(Res.InvalidDNFormat), "distinguishedName");
                }

                dnComponents[i].Value = subComponents[1].Trim();
                if (dnComponents[i].Value.Length == 0)
                {
                    throw new ArgumentException(Res.GetString(Res.InvalidDNFormat), "distinguishedName");
                }
            }
            return dnComponents;
        }
Esempio n. 2
-1
		internal static Component[] GetDNComponents(string distinguishedName)
		{
			string[] strArrays = Utils.Split(distinguishedName, ',');
			Component[] componentArray = new Component[strArrays.GetLength(0)];
			int num = 0;
			while (num < strArrays.GetLength(0))
			{
				string[] strArrays1 = Utils.Split(strArrays[num], '=');
				if (strArrays1.GetLength(0) == 2)
				{
					componentArray[num].Name = strArrays1[0].Trim();
					if (componentArray[num].Name.Length != 0)
					{
						componentArray[num].Value = strArrays1[1].Trim();
						if (componentArray[num].Value.Length != 0)
						{
							num++;
						}
						else
						{
							throw new ArgumentException(Res.GetString("InvalidDNFormat"), "distinguishedName");
						}
					}
					else
					{
						throw new ArgumentException(Res.GetString("InvalidDNFormat"), "distinguishedName");
					}
				}
				else
				{
					throw new ArgumentException(Res.GetString("InvalidDNFormat"), "distinguishedName");
				}
			}
			return componentArray;
		}
Esempio n. 3
-1
		internal static bool IsValidDNFormat(string distinguishedName)
		{
			string[] strArrays = Utils.Split(distinguishedName, ',');
			Component[] componentArray = new Component[strArrays.GetLength(0)];
			int num = 0;
			while (num < strArrays.GetLength(0))
			{
				string[] strArrays1 = Utils.Split(strArrays[num], '=');
				if (strArrays1.GetLength(0) == 2)
				{
					componentArray[num].Name = strArrays1[0].Trim();
					if (componentArray[num].Name.Length != 0)
					{
						componentArray[num].Value = strArrays1[1].Trim();
						if (componentArray[num].Value.Length != 0)
						{
							num++;
						}
						else
						{
							return false;
						}
					}
					else
					{
						return false;
					}
				}
				else
				{
					return false;
				}
			}
			return true;
		}
 internal static Component[] GetDNComponents(string distinguishedName)
 {
     string[] strArray = Split(distinguishedName, ',');
     Component[] componentArray = new Component[strArray.GetLength(0)];
     for (int i = 0; i < strArray.GetLength(0); i++)
     {
         string[] strArray2 = Split(strArray[i], '=');
         if (strArray2.GetLength(0) != 2)
         {
             throw new ArgumentException(Res.GetString("InvalidDNFormat"), "distinguishedName");
         }
         componentArray[i].Name = strArray2[0].Trim();
         if (componentArray[i].Name.Length == 0)
         {
             throw new ArgumentException(Res.GetString("InvalidDNFormat"), "distinguishedName");
         }
         componentArray[i].Value = strArray2[1].Trim();
         if (componentArray[i].Value.Length == 0)
         {
             throw new ArgumentException(Res.GetString("InvalidDNFormat"), "distinguishedName");
         }
     }
     return componentArray;
 }
 internal static bool IsValidDNFormat(string distinguishedName)
 {
     string[] strArray = Split(distinguishedName, ',');
     Component[] componentArray = new Component[strArray.GetLength(0)];
     for (int i = 0; i < strArray.GetLength(0); i++)
     {
         string[] strArray2 = Split(strArray[i], '=');
         if (strArray2.GetLength(0) != 2)
         {
             return false;
         }
         componentArray[i].Name = strArray2[0].Trim();
         if (componentArray[i].Name.Length == 0)
         {
             return false;
         }
         componentArray[i].Value = strArray2[1].Trim();
         if (componentArray[i].Value.Length == 0)
         {
             return false;
         }
     }
     return true;
 }
Esempio n. 6
-1
        //
        // A valid DN is one which can be split based on ',' into components and each
        // components contains two tokens separated by '='
        //
        internal static bool IsValidDNFormat(string distinguishedName)
        {
            Debug.Assert(distinguishedName != null, "Utils.GetDNComponents: distinguishedName is null");

            // First split by ','
            string[] components = Split(distinguishedName, ',');
            Component[] dnComponents = new Component[components.GetLength(0)];

            for (int i = 0; i < components.GetLength(0); i++)
            {
                // split each component by '='
                string[] subComponents = Split(components[i], '=');
                if (subComponents.GetLength(0) != 2)
                {
                    return false;
                }

                dnComponents[i].Name = subComponents[0].Trim();
                if (dnComponents[i].Name.Length == 0)
                {
                    return false;
                }

                dnComponents[i].Value = subComponents[1].Trim();
                if (dnComponents[i].Value.Length == 0)
                {
                    return false;
                }
            }
            return true;
        }