directoryservices

DirectoryEntry.NativeObject throws access denied for a user in Administrators group in windows 2008

别来无恙 提交于 2019-12-12 07:23:07
问题 I have a local user, which is member of Administrators local group. When I run this code: using System; using System.DirectoryServices; namespace nanttest { class Program { public static void Main(string[] args) { using(DirectoryEntry entry = new DirectoryEntry("IIS://localhost/W3SVC")) { object absobject = entry.NativeObject; Console.WriteLine("Name: {0}", entry.Name); } Console.Write("Press any key to continue . . . "); Console.ReadKey(true); } } } I receive: Unhandled Exception: System

Error with Directory.Services when on production

柔情痞子 提交于 2019-12-12 01:59:14
问题 The following code works fine in Visual Studio Development enviroment on my local machine. However when I move the files to a Windows 2008 R2 IIS 7.5 machine I get the following error: [DirectoryServicesCOMException (0x80072020): An operations error occurred. ] _Default.GetFullName(String strLoginName, String& STR_FIRST_NAME, String& STR_LAST_NAME, String& STR_DISPLAY_NAME, String& STR_MAIL, String& STR_OFFICE_PHONE, String& STR_ADDRESS) in c:\AuthTest\Default.aspx.cs:87 _Default.Page_Load

PrincipalContext.ValidateCredentials doesn't set lastLogon date for user

别等时光非礼了梦想. 提交于 2019-12-12 01:11:57
问题 I'm validating users in an Active Directory store as follows: // using System.DirectoryServices.AccountManagement; // located in System.DirectoryServices.AccountManagement.dll using (var context = new PrincipalContext(ContextType.Domain, server, container, ContextOptions.Negotiate, validateUsername, validatePassword)) { var valid = context.ValidateCredentials(validateUsername, validatePassword); if (valid) { Console.WriteLine("SUCCESS!"); using (var userContext = UserPrincipal.FindByIdentity

Check if List of Users are valid against adfs in C#

☆樱花仙子☆ 提交于 2019-12-12 01:09:17
问题 I have a requirement to check if the users in my application are active users in active directory. I need to send a notification when one of the user alias becomes invalid. In most of the examples I see validating only one user at a time against ADFS using LDAP which is going to take a very long time large number of users. Is there any way by which I can validate by sending a list of users and validate, so that it will be faster? Thanks. 回答1: Out the box in ADFS, no. This sounds like

How do you backup IIS's metabase in C#?

梦想与她 提交于 2019-12-12 00:54:29
问题 exact code will be helpful. I assume the DirectoryServices namespace does it but I can't find the method that does it. I need actual C# code. All the samples I found so far are VB or VBScript. The C# examples I found are for reading/setting ADSI properties. A command like backup seems to have a certain .NET syntax which I am not clear how to use. In VB there's a straightforward backup command. Need an equivalent in .NET. 回答1: You'll need to use ADSI objects. The IIsComputer.Backup method is

DirectoryServices - “Network logon failure unknown user name or bad password”

好久不见. 提交于 2019-12-11 23:39:16
问题 I'm building a little library that can be used to query Active Directory resources. I've tested it out before and it works as I expect it to. The problem is I have created a brand new VMWare virtual computer with Windows Server 2003 installed, created the domain, added some dummy objects and now when I try to run the application I get the error: "Network logon failure unknown user name or bad password". //Example 1: Find all users in Active Directory. Be sure your LDAP connection string is

AD: Group does not have a primaryGroupToken attribute

余生颓废 提交于 2019-12-11 19:12:44
问题 I need to change the primary group of a user, so I can delete it from it's current one. But my group does not have the attribute "primaryGroupToken", which I need in order to change the primary group of the user. Here is a screenshot of the attribute editor: Obviously, my code responds nothing: Dim domainGroup As New DirectoryEntry("LDAP://our.domain/CN=Domain Users,CN=Users,DC=our,DC=domain") Dim domainGroupGroupToken As String = domainGroup.Properties("primaryGroupToken").Value.ToString()

get active directory users whose FirstName in active directory is not empty or NULL

梦想的初衷 提交于 2019-12-11 17:59:34
问题 Searcher.Filter = "(&(objectCategory=person)(objectClass=user)(!givenName=""))" I'am using the above active directory search filter to try and get users whose FirstName in active directory is not empty or NULL but the filter still returns null entries. What should I change in the filter to only retreive users with a first name that is not NULL or Empty 回答1: Can you try : Searcher.Filter = "(&(objectCategory=user)(objectClass=user)(givenName=*))" To build a filter you can use registered query

Using statement with directoryservices

南笙酒味 提交于 2019-12-11 14:53:47
问题 Could you help me and tell if im using the "using statement" correctly in my directoryservice function that gets distingushed name from my Active Directory. I want to dispose and close objects correctly. Code: Public Function GetObjectDistinguishedName(ByVal objClass As objectClass, _ ByVal returnValue As returnType, _ ByVal objName As String, ByVal LdapDomain As String, _ Optional ByVal includeLdapPrefix As Boolean = True) As String Dim distinguishedName As String = String.Empty Dim

How do I convert type _ComObject to a native type like Long or other (getting cast error)?

雨燕双飞 提交于 2019-12-11 14:16:00
问题 I am trying to get the LastLogonTimestamp from Active Directory by calling Principal.ExtensionGet("lastLogonTimestamp") VB.NET code: <DirectoryProperty("lastLogonTimestamp")> Public Property LastLogonTimestamp() As Date? ' no matter what this type is, I cannot cast the Object coming in Get Dim valueArray = ExtensionGet("lastLogonTimestamp") If valueArray Is Nothing OrElse valueArray.Length = 0 Then Return Nothing Return DateTime.FromFileTimeUtc(valueArray(0)) End Get Set(value As Date?)