active-directory

Active Directory COM Exception - An operations error occurred (0x80072020)

心已入冬 提交于 2019-12-27 17:39:27
问题 I am getting an intermittent COM Exception " An operations error occurred (0x80072020) " (shown below) when I try and query Active Directory using the method GroupPrincipal.FindByIdentity Here is my code: PrincipalContext ctx = new PrincipalContext(ContextType.Domain, Environment.UserDomainName); GroupPrincipal groupPrincipal = GroupPrincipal.FindByIdentity(ctx, IdentityType.Name, "Group to find"); I am receiving Exception: Inner Exception: System.Runtime.InteropServices.COMException

Active Directory COM Exception - An operations error occurred (0x80072020)

青春壹個敷衍的年華 提交于 2019-12-27 17:39:02
问题 I am getting an intermittent COM Exception " An operations error occurred (0x80072020) " (shown below) when I try and query Active Directory using the method GroupPrincipal.FindByIdentity Here is my code: PrincipalContext ctx = new PrincipalContext(ContextType.Domain, Environment.UserDomainName); GroupPrincipal groupPrincipal = GroupPrincipal.FindByIdentity(ctx, IdentityType.Name, "Group to find"); I am receiving Exception: Inner Exception: System.Runtime.InteropServices.COMException

How to get all the AD groups for a particular user?

老子叫甜甜 提交于 2019-12-27 17:01:50
问题 I checked this post already. But it doesn't answer my question. I want to get all the active directory groups in which a particular user is a member. I've written the following code. But I'm not able to proceed further as I don't know how to give the filter and how to access the properties. class Program { static void Main(string[] args) { DirectoryEntry de = new DirectoryEntry("LDAP://mydomain.com"); DirectorySearcher searcher = new DirectorySearcher(de); searcher.Filter = "(&(ObjectClass

How to programmatically change Active Directory password

两盒软妹~` 提交于 2019-12-27 13:37:07
问题 I have a set of test accounts that are going to be created but the accounts will be setup to require password change on the first login. I want to write a program in C# to go through the test accounts and change the passwords. 回答1: You can use the UserPrincipal class' SetPassword method, provided you have enough privileges, once you've found the correct UserPrincipal object. Use FindByIdentity to look up the principal object in question. using (var context = new PrincipalContext( ContextType

powershell: displaying array data next to string data?

。_饼干妹妹 提交于 2019-12-25 18:35:38
问题 When i open the export below in excel, all i can see for MemberOf is System.String[]. How can i show each member with the name, description, userprincipalname next to it? $Accounts | Get-QADUser | ft name, description, UserPrincipalName, memberOf | Export-Csv C:\Temp\Useraccounts.csv 回答1: Try this: $Accounts | Get-QADUser | select name, description, UserPrincipalName, @{ n="memberof"; e={ $_.memberof }} | Export-Csv -NoTypeInformation .\file.csv Some info for 'calculated property' here Some

Search powershell by CSV for Computer name

≡放荡痞女 提交于 2019-12-25 18:35:11
问题 Ive been tasked with the issue of searching a CSV file that has over 1000 computer names in it. I was wondering if there was a way to search AD with Get-ADComputer by the CSV file for the computer names and return the output if they exist in active directory. So far I haven't been able to come up with anything except of doing it manually. 回答1: You can foreach through the computer names from the csv, but that could take a while for 1000 computers. An alternative is to build an LDAP filter from

Get LastLogonUser and LastLogonDate on computers in AD

蹲街弑〆低调 提交于 2019-12-25 18:25:08
问题 We can use Get-ADComputer $computerName -Properties LastLogonDate to get LastLogonDate . But how to know which user did the Last Logon? Get-ADUser has a LastLogon property, but it seems we could not use it to decide which computer the user logon. 回答1: You're misunderstanding the meaning of LastLogonDate in this context. It's the timestamp of when the computer account last authenticated against the domain, not the timestamp of when a user last logged into that particular computer. To determine

Compare-Object on two AD user accounts

泄露秘密 提交于 2019-12-25 16:29:10
问题 Can anyone please give some advice on comparing two ADAccount Objects in PowerShell (v2). Whenever I run a comparison with Compare-Object, it only shows the difference in the Distinguished name, not the differences in the fields of those accounts. Short of separately comparing $ADUser.Modified , or $ADUser.DisplayName , etc for every field I want to check, I'm at a loss. Is there a way to compare each and every field in the ADUser object across the two accounts, showing which fields are

C# search for user in AD

回眸只為那壹抹淺笑 提交于 2019-12-25 16:26:51
问题 I'm not a programmer by nature so I apologize in advance. I've searched far and wide and have found bits and pieces of 10 different ways to do one thing. What I'm trying to do seems very simple but I'm missing it...I need to search Active Directory using a first name and last name and display all users who match in a listbox. Can someone point me in the right direction, or if someone has already asked the same question link me to it? Thanks in advance! 回答1: Try something like this:-

C# search for user in AD

心已入冬 提交于 2019-12-25 16:26:22
问题 I'm not a programmer by nature so I apologize in advance. I've searched far and wide and have found bits and pieces of 10 different ways to do one thing. What I'm trying to do seems very simple but I'm missing it...I need to search Active Directory using a first name and last name and display all users who match in a listbox. Can someone point me in the right direction, or if someone has already asked the same question link me to it? Thanks in advance! 回答1: Try something like this:-