gpt4 book ai didi

sql-server-2005 - SQL CLR 存储过程查询事件目录

转载 作者:行者123 更新时间:2023-12-02 02:30:20 26 4
gpt4 key购买 nike

我需要从存储在 Active Directory 上的数据库中的用户那里获取一些信息,我有一个简单的函数来执行此操作:

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());
}
}

按我的意愿从 WinForm 运行,但在 SQL Server 项目类型中,我无法将 namespace System.DirectoryServices 添加到引用中。

谁知道为什么?

问候

乙肝

最佳答案

参见:Supported .NET Framework Libraries

Unsupported libraries can still be called from your managed stored procedures, triggers, user-defined functions, user-defined types, and user-defined aggregates. The unsupported library must first be registered in the SQL Server database, using the CREATE ASSEMBLY statement, before it can be used in your code. Any unsupported library that is registered and run on the server should be reviewed and tested for security and reliability.

For example, the System.DirectoryServices namespace is not supported. You must register the System.DirectoryServices.dll assembly with UNSAFE permissions before you can call it from your code. The UNSAFE permission is necessary because classes in the System.DirectoryServices namespace do not meet the requirements for SAFE or EXTERNAL_ACCESS. For more information, see CLR Integration Programming Model Restrictions and CLR Integration Code Access Security.

关于sql-server-2005 - SQL CLR 存储过程查询事件目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4027136/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com