コード例 #1
0
ファイル: LdapEntry.cs プロジェクト: wfu8/lightwave
        //Override
        public List <string> getAttributeNames()
        {
            IntPtr        attributePointer = IntPtr.Zero, berPointer = IntPtr.Zero;
            List <string> attributeList = new List <string>();

            try
            {
                attributePointer = LdapClientLibrary.ldap_first_attribute(this._message.GetConnection().GetIntPtr(), this._entry, out berPointer);
                while (attributePointer != IntPtr.Zero)
                {
                    var attributeName = Marshal.PtrToStringAnsi(attributePointer);
                    attributeList.Add(attributeName);
                    LdapClientLibrary.ldap_memfree(attributePointer);
                    attributePointer = LdapClientLibrary.ldap_next_attribute(this._message.GetConnection().GetIntPtr(), this._entry, berPointer);
                }
                return(attributeList);
            }
            finally
            {
                LdapClientLibrary.ldap_value_free(attributePointer);
                LdapClientLibrary.ber_free(berPointer, 0);
            }
        }
コード例 #2
0
ファイル: LdapEntry.cs プロジェクト: wfu8/lightwave
        //Override
        public List <LdapValue> getAttributeValues(string attributeName)
        {
            List <LdapValue> attributeValues  = new List <LdapValue>();
            IntPtr           attributePointer = IntPtr.Zero;
            int i = 0;

            try
            {
                attributePointer = LdapClientLibrary.ldap_get_values(this._message.GetConnection().GetIntPtr(), this._entry, attributeName);
                var count = LdapClientLibrary.ldap_count_values(attributePointer);
                while (i < count)
                {
                    var attributeValuePointer = Marshal.ReadIntPtr(attributePointer, System.Runtime.InteropServices.Marshal.SizeOf(attributePointer) * i);
                    var attributeValue        = new LdapValue(Marshal.PtrToStringAnsi(attributeValuePointer));
                    attributeValues.Add(attributeValue);
                    i++;
                }
                return(attributeValues);
            }
            finally
            {
                LdapClientLibrary.ldap_value_free(attributePointer);
            }
        }