If you’re experiencing an unknown entry.bind directory error on your system, this article should help.
Quick and Easy PC Repair
After you start the application, give a console to run it using your credentials, eg. to “you”.
Where is the WCF service running? IIS? Most likely, he is running under a separate large account that no longer has permission to query Active Directory.
You can either try to get the WCF impersonation to work so that it passes your own credentials, or you can specify a username/password when entering your DirectoryEntry:
DirectoryEntry directoryEntry = new DirectoryEntry("LDAP://someserver.contoso.com/DC=contoso,DC=com", Login: Password);
Ok, but that might be the wrong review (usually a dispute in over 80% of the defenses I see).
DirectorySearcher directorySearcher = new DirectorySearcher(directoryEntry);directorySearcher.Filter = string.Format("(&(objectClass=user)(objectCategory=user) (sAMAccountName=0))", username);directorySearcher.PropertiesToLoad.Add("msRTCSIP-PrimaryUserAddress");the result of var is directorySearcher.FindOne(); if(Result.!= null) if(result.Properties["msRTCSIP-PrimaryUserAddress"] != null) var resultValue - result.Properties["msRTCSIP-PrimaryUserAddress"];
My approach is this: why not tell the entire
DirectorySearcher which component you want tointerested? Then you don’t have to do a bit more to remove the whole
DirectoryEntry from the search results (it should be faster), and since you’ve told the search engine a list of addresses to look for this property, indeed it will load next to the search result – so save it if it’s null (no value set) and you can easily restore it.
I have a C# windows service to create/update AD user properties. I’m using PrincipalContext to get a class that does AD operations. You have an exception to this rule when creating an Active Directory user.
The same code works well for updating properties for classic users. The service account also has sufficient permissions to manually create users in AD. The problem only occurs when we try to programmatically create PC users.
System.Reflection.TargetInvocationException: An exception was recently thrown from the target of all invocations. —> System.DirectoryServices.AccountManagement.PrincipalOperationException: Unknown error (0x80005000) —> System.Runtime.InteropServices.Unknown Exception: Error (0x80005000)
in System.DirectoryServices.DirectoryEntry.Bind(throwIfFail boolean)
in System.DirectoryServices.AccountManagement.ADStoreCtx.IsContainer(DirectoryEntry of)
in System.DirectoryServices.AccountManagement.ADStoreCtx..ctor(DirectoryEntry ctxBase, boolean ownCtxBase, string username, string password, ContextOptions options)
in System.DirectoryServices.AccountManagement.PrincipalContext.CreateContextFromDirectoryEntry(DirectoryEntry entry)
Department ID: 6dc2ef176aad742f