示例#1
0
        private string GetProperty(AD.SearchResult searchResult, string PropertyName)
        {
            string resultado;
            string otroValor;

            resultado = string.Empty;
            foreach (string propertyKey in searchResult.Properties.PropertyNames)
            {
                AD.ResultPropertyValueCollection valueCollection = searchResult.Properties[propertyKey];
                foreach (var propertyValue in valueCollection)
                {
                    if (propertyKey == PropertyName)
                    {
                        resultado = propertyValue.ToString();
                    }
                    else
                    {
                        otroValor = propertyValue.ToString();
                    }
                }
            }
            return(resultado);
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="resultPropertyValueCollection">
 /// </param>
 public ResultPropertyValueCollectionWrap(ResultPropertyValueCollection resultPropertyValueCollection)
 {
     this.resultPropertyValueCollection = resultPropertyValueCollection;
 }
 public List<string> PropertyValueList(ResultPropertyValueCollection resultPropertyValueCollection)
 {
     var propertyCount = resultPropertyValueCollection.Count;
     if (propertyCount != 0)
     {
         var list = new List<string>();
         for (var i = 0; i < propertyCount; i++)
         {
             list.Add(resultPropertyValueCollection[i].ToString());
         }
         return list;
     }
     return new List<string>();
 }
 public string PropertyValue(ResultPropertyValueCollection resultPropertyValueCollection)
 {
     if (resultPropertyValueCollection.Count != 0)
         return resultPropertyValueCollection[0].ToString();
     return string.Empty;
 }
 public ADGroupMemberCollection(System.DirectoryServices.ResultPropertyValueCollection input, string[] neededProperties)
     : this(input)
 {
     this.propertiesToGet = neededProperties;
 }
示例#6
0
		/// <summary>
		/// Gets the RP.
		/// </summary>
		/// <param name="rp">The rp.</param>
		/// <returns></returns>
		private object GetRP(
			ResultPropertyValueCollection rp )
		{
			if ( rp == null )
			{
				LogCentral.Current.LogDebug(
					string.Format(
					@"ActiveDirectory.GetRP(): rp is null, returning NULL."
					) );

				return null;
			}
			else if ( rp.Count <= 0 )
			{
				LogCentral.Current.LogDebug(
					string.Format(
					@"ActiveDirectory.GetRP(): rp is empty, returning NULL."
					) );

				return null;
			}
			{
				object o = rp[0];

				LogCentral.Current.LogDebug(
					string.Format(
					@"ActiveDirectory.GetRP(): rp is non-null, returning rp[0] with a value of '{0}'.",
					o
					) );

				return o;
			}
		}
 /// <include file='doc\ResultPropertyCollection.uex' path='docs/doc[@for="ResultPropertyCollection.CopyTo"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public void CopyTo(ResultPropertyValueCollection[] array, int index)
 {
     Dictionary.Values.CopyTo((Array)array, index);
 }
示例#8
0
 internal dSPropertyValueCollection(ResultPropertyValueCollection rc) { _rc = rc; }
示例#9
0
 internal void Add(string name, ResultPropertyValueCollection value)
 {
     Dictionary.Add(name.ToLowerInvariant(), value);
 }
示例#10
0
 private string getInfo(ResultPropertyValueCollection rpv)
 {
     if(rpv.Count>0)
     {
         if(rpv[0] is byte[])
         {
             return System.Text.Encoding.Default.GetString(rpv[0] as byte[]);
         }
         else
         {
             return rpv[0].ToString();
         }
     }
     return "";
 }
        private string GetStringList(ResultPropertyValueCollection coll)
        {
          string result = "";
          foreach (string prop in coll)
          {
            if (result.Length > 0)
              result += string.Format(", {0}", prop);
            else result += prop;
          }

          return string.Format("[ {0} ]", result); ;
        }
 private string GetFirstString(ResultPropertyValueCollection coll)
 {
     if (coll != null && coll.Count > 0 && coll[0] != null)
         return coll[0].ToString();
     else
         return "";
 }
			private static string ConcatPropertyValues(ResultPropertyValueCollection values)
			{
				List<string> propValues = new List<string>();

				foreach (var propValue in values)
				{
					propValues.Add(propValue.ToString());
				}

				return string.Join(", ", propValues);
			}
 internal void Add(string name, ResultPropertyValueCollection value)
 {
     Dictionary.Add(name.ToLower(CultureInfo.InvariantCulture), value);
 }
        private static void LoadFromActiveDirectory()
        {
            string domainName = "LDAP://ou=osl,dc=win,dc=lottery,dc=state,dc=or,dc=us";

            AD.DirectoryEntry    dirEntry = new AD.DirectoryEntry();
            AD.DirectorySearcher searcher;
            dirEntry.Path = domainName;
            dirEntry.AuthenticationType = AD.AuthenticationTypes.Secure;
            searcher             = new AD.DirectorySearcher();
            searcher.SearchRoot  = dirEntry;
            searcher.SearchScope = AD.SearchScope.Subtree;
            //searcher.Filter = "(&(objectCategory=person)(sAMAccountName=*))";
            searcher.Filter = "(&(objectCategory=person))";
            AD.SearchResultCollection results = searcher.FindAll();
            foreach (AD.SearchResult sr in results)
            {
                string adName       = "";
                string adDepartment = "";
                string employeeId   = "";
                string emailaddr    = "";
                AD.ResultPropertyValueCollection departments = sr.Properties["department"];
                if (departments != null && departments.Count > 0)
                {
                    adDepartment = departments[0].ToString();
                }
                AD.ResultPropertyValueCollection employeeIds = sr.Properties["employeeid"];
                if (employeeIds != null && employeeIds.Count > 0)
                {
                    employeeId = (string)employeeIds[0];
                }
                AD.ResultPropertyValueCollection names = sr.Properties["Name"];
                if (names != null && names.Count > 0)
                {
                    adName = (string)names[0];
                }
                if (!string.IsNullOrEmpty(adName) && !string.IsNullOrEmpty(adDepartment))
                // Some non-security lottery staff do NOT have employee ID in Active Directory!
                // ALL OSP staff do NOT have an employee ID.
                //          (
                //          !string.IsNullOrEmpty(employeeId) || (adDepartment.ToLower() == "security")
                //          )
                //         )
                {
                    if (!adName.ToLower().Contains("-adm"))
                    {
                        AD.ResultPropertyValueCollection emails = sr.Properties["mail"];
                        if (emails != null && emails.Count > 0)
                        {
                            emailaddr = (string)emails[0];
                        }
                        if (!string.IsNullOrEmpty(adName))
                        {
                            if (adDepartment.ToLower() == "information technology" || adDepartment.StartsWith("IT"))
                            {
                                _ITPersonNames.Add(adName);
                                if (!string.IsNullOrEmpty(emailaddr))
                                {
                                    _ITEmailAddresses.Add(emailaddr);
                                }
                            }
                        }
                        if (!string.IsNullOrEmpty(emailaddr))
                        {
                            _AllEmailAddresses.Add(emailaddr);
                        }
                    }
                }
            }
        }
 public void CopyTo(ResultPropertyValueCollection[] array, int index)
 {
 }
        /// <summary>
        /// Gets the attribute value.
        /// </summary>
        /// <param name="propertyValues">The property values.</param>
        /// <returns>System.Object.</returns>
        /// <exception cref="System.InvalidOperationException">Multi-value attributes are not supported.</exception>
        private static object GetAttributeValue(ResultPropertyValueCollection propertyValues)
        {
            if (propertyValues == null || propertyValues.Count == 0)
                return null;

            if (propertyValues.Count > 1)
                throw new InvalidOperationException("Multi-value attributes are not supported.");

            return propertyValues[0];
        }
示例#18
0
 internal void Add(string name, ResultPropertyValueCollection value)
 {
     Dictionary.Add(name.ToLower(CultureInfo.InvariantCulture), value);
 }
示例#19
0
		//add a ResultPropertyValueCollection based on key 
		internal void Add(string key, ResultPropertyValueCollection rpcoll) 
		{ 
			this.Dictionary.Add(key.ToLower(), rpcoll); 
		} 
示例#20
0
		/// <summary>
		/// Internal helper.
		/// </summary>
		/// <param name="c">The c.</param>
		/// <returns></returns>
		private static byte[] GetPropertyValueByteArray(
			ResultPropertyValueCollection c )
		{
			if ( c == null || c.Count <= 0 || c[0] == null )
			{
				return null;
			}
			else
			{
				return (byte[])c[0];
			}
		}
示例#21
0
		public void CopyTo (ResultPropertyValueCollection[] copy_to, int index)
		{
			foreach (ResultPropertyValueCollection vals in Values)
				copy_to[index++] = vals;
		}
示例#22
0
 //add a ResultPropertyValueCollection based on key
 internal void Add(string key, ResultPropertyValueCollection rpcoll)
 {
     this.Dictionary.Add(key.ToLower(), rpcoll);
 }
 public ADGroupMemberCollection(System.DirectoryServices.ResultPropertyValueCollection input)
 {
     this.source = input;
 }