SQL CLR stored Active Directory Query Procedure

I need to get some information from users in a database that is stored in Active Directory, I have a simple function for this:

using (DirectoryEntry de = new DirectoryEntry("LDAP://ANYGIVENDOMAIN"))
{
    using (DirectorySearcher adSearch = new DirectorySearcher(de))
    {
        adSearch.Filter = "(sAMAccountName=jdoe)";                  
        SearchResult adSearchResult = adSearch.FindOne();

        StringBuilder sb = new StringBuilder();
        sb.AppendLine(adSearchResult.Properties["displayname"][0].ToString());
        sb.AppendLine(adSearchResult.Properties["givenName"][0].ToString());
        sb.AppendLine(adSearchResult.Properties["objectSid"][0].ToString());
        sb.AppendLine(adSearchResult.Properties["description"][0].ToString());
        sb.AppendLine(adSearchResult.Properties["objectGUID"][0].ToString());
    }
}

Starting from WinForm is done the way I want, but in SQL Server Project Type I cannot add the System.DirectoryServices namespace to the links.

Does anyone know why?

Hi

Je

+3
source share
1 answer

See: Supported .NET Framework Libraries

, , , . SQL Server, CREATE ASSEMBLY, . , .

, System.DirectoryServices . System.DirectoryServices.dll UNSAFE, . UNSAFE , System.DirectoryServices SAFE EXTERNAL_ACCESS. , . CLR CLR .

+2

Source: https://habr.com/ru/post/1771562/


All Articles