我正在使用 .NET Forms 应用程序中的这段代码来尝试创建一个 PrincipalContext 对象。
var oPrincipalContext = new PrincipalContext(
ContextType.Domain,
"mydomain.workgroup",
"CN=users,CN=mydomain,CN=workgroup",
ContextOptions.Bind,
"ADAdmin",
"ADAdminPassword");
我也试过这个,但得到了同样的错误。
var oPrincipalContext = new PrincipalContext(
ContextType.Domain,
"mydomain.workgroup",
"CN=users,CN=mydomain,CN=workgroup",
ContextOptions.Negotiate,
"ADAdmin",
"ADAdminPassword");
我也尝试过ADAdmin@mydomain.workgroup
作为用户ID。
我收到此错误
Message=An operations error occurred.
StackTrace= at System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInit()
at System.DirectoryServices.AccountManagement.PrincipalContext.DoDomainInit()
at System.DirectoryServices.AccountManagement.PrincipalContext.Initialize()
at System.DirectoryServices.AccountManagement.PrincipalContext.get_ConnectedServer()
at WindowsFormsApplication1.Form1.button1_Click(Object sender, EventArgs e)
InnerException=An operations error occurred.
StackTrace= at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_SchemaEntry()
at System.DirectoryServices.AccountManagement.ADStoreCtx.IsContainer(DirectoryEntry de)
at System.DirectoryServices.AccountManagement.ADStoreCtx..ctor(DirectoryEntry ctxBase, Boolean ownCtxBase, String username, String password, ContextOptions options)
at System.DirectoryServices.AccountManagement.PrincipalContext.CreateContextFromDirectoryEntry(DirectoryEntry entry)
at System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInit()
我以在 AD 中具有 DomainAdmin 权限的用户身份登录。
我运行它的计算机在 AD 中具有 DomainAdmin 权限。
此链接有一个解决方案,但它IIS
适用于我,但对我不起作用。
该解决方案也不起作用。