Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Display thumbnail photo from active directory

$
0
0

Hi,

I am using Asp.net core and Novell Directory LDAP Netstandard lib.

string ldapHost = ****;
            int ldapPort = LdapConnection.DEFAULT_PORT;
            String loginDN = ****;
            String password = ****;
            String searchBase = ****;
            String searchFilter = "(cn=*John Smith*)";

            LdapConnection conn = new LdapConnection();
            Console.WriteLine("Connecting to:" + ldapHost);
            conn.Connect(ldapHost, ldapPort);
            conn.Bind(loginDN, password);
            LdapSearchResults lsc = conn.Search(searchBase,
                                                LdapConnection.SCOPE_SUB,
                                                searchFilter, // Search Filter
                                                null,
                                                false); //No attributes are returned


            while (lsc.hasMore())
            {
                LdapEntry nextEntry = null;
                try
                {
                    nextEntry = lsc.next();
                }
                catch (LdapException e)
                {
                    Console.WriteLine("Error: " + e.LdapErrorMessage);
                    continue;
                }

                LdapAttributeSet attributeSet = nextEntry.getAttributeSet();
                IEnumerator ienum = attributeSet.GetEnumerator();

                while (ienum.MoveNext())
                {
                    LdapAttribute attribute = (LdapAttribute)ienum.Current;
                    string attributeName = attribute.Name;

                    string attributeVal = attribute.StringValue;

                    if (!Base64.isLDIFSafe(attributeVal))
                    {
                        byte[] tbyte = SupportClass.ToByteArray(attributeVal);
                        attributeVal = Base64.encode(SupportClass.ToSByteArray(tbyte));
                    }

                    if (attributeName == "thumbnailPhoto")
                    {
                        //Console.WriteLine(attributeName + ": " + attributeVal);
                    }

                }
            }
            conn.Disconnect();

How to display thumbnail photo from active directory in Controller Web Api?
I am waiting for your response.
Thanks in advance!


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>