adsi

[ADSI]::Exists throws an exception instead of returning False

a 夏天 提交于 2019-12-05 11:04:53
I'm trying to create a user using the ADSI object if it doesn't already exist. Here are the strange results I'm getting #Check a user that I know exists [ADSI]::Exists("WinNT://localhost/micah,user") #True #Check a group that I know exists [ADSI]::Exists("WinNT://localhost/administrators,group") #True #Check a group that DOESN'T exist [ADSI]::Exists("WinNT://localhost/whoops,group") #False #Check a user that DOESN'T exist (NOT specifying that the obect is a user) [ADSI]::Exists("WinNT://localhost/test") #False (This works fine) #Check a user that DOESN'T exist (specifying that the obect IS a

Trying to create a new Active Directory user, Invoke(“SetPassword”,pwd) throws “The RPC server is unavailable”

丶灬走出姿态 提交于 2019-12-05 05:37:27
问题 I'm trying to create a new user on my development active directory server using .NET System.DirectoryServices namespace. I try using the following code: DirectoryEntry dirEntry = new DirectoryEntry(path, "TESTDOM\\Administrator", "2109password", AuthenticationTypes.Secure | AuthenticationTypes.ServerBind); object o = dirEntry.NativeObject; DirectoryEntry newUser = dirEntry.Children.Add("CN=NewUser4", "user"); newUser.Properties["samAccountName"].Value = "NewUser4"; newUser.Properties[

How do I query effective permissions on an Active Directory Object?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 20:28:27
问题 I'm trying to programmatically determine whether the current user has certain permissions on a given Active Directory object (specifically in this case, I'm trying to determine whether the user has the "Send As" permission for another Exchange user or distribution list object). I already figured out how to access the ntSecurityDescriptor attribute using ADSI: I can enumerate the ACEs in the IADsSecurityDescriptor 's DiscretionaryACL property. But: How do I determine from that data whether the

Updating Active Directory user properties in Active Directory using Powershell

▼魔方 西西 提交于 2019-12-04 13:51:23
In a Windows Server 2003 R2 environment, using Powershell v2.0, how would one duplicate the functionality of Set-QADUser to update user properties in Active Directory, like their phone number and title? The trick here being, I would like to do this without depending on Set-QADUser and I do not have the option to use the Server 2008's commandlets, yet. Thanks. Piecing things together from around the internet, I came up with this... function Get-ADUser( [string]$samid=$env:username){ $searcher=New-Object DirectoryServices.DirectorySearcher $searcher.Filter="(&(objectcategory=person)(objectclass

Add IIS AppPool\\ASP.NET v4.0 to local windows group

巧了我就是萌 提交于 2019-12-04 03:29:08
I'm trying to script with PowerShell the act of adding the user IIS AppPool\ASP.NET v4.0 to the Performance Monitor Users group, to be able to use custom performance counters from an ASP.NET application. But, I can't figure out how to address the automatically created ASP.NET user using ADSI. This works for me: $computer = $env:COMPUTERNAME; $user = [ADSI]"WinNT://$computer/Administrator,user" $groupToAddTo = "TestGroup" $parent = [ADSI]"WinNT://$computer/$groupToAddTo,group" $parent.Add($user.Path) However, I can't figure out how to find the ASP.NET v4.0 user: $computer = $env:COMPUTERNAME; #

Create local user with PowerShell (Windows Vista)

房东的猫 提交于 2019-12-03 15:02:54
I've installed PowerShell recently and one of the first things I started looking for was how to create a new user. After looking for some time I still haven't found this. I have a little experience in bash on linux and find it very effective. Creating users there is trivial. Is there an easy\built-in way to create a local user with PowerShell? Thank you. BobbyShaftoe You can use the localhost's ADSI : function create-account ([string]$accountName = "testuser") { $hostname = hostname $comp = [adsi] "WinNT://$hostname" $user = $comp.Create("User", $accountName) $user.SetPassword("Password1")

How do I query effective permissions on an Active Directory Object?

独自空忆成欢 提交于 2019-12-03 12:37:22
I'm trying to programmatically determine whether the current user has certain permissions on a given Active Directory object (specifically in this case, I'm trying to determine whether the user has the "Send As" permission for another Exchange user or distribution list object). I already figured out how to access the ntSecurityDescriptor attribute using ADSI: I can enumerate the ACEs in the IADsSecurityDescriptor 's DiscretionaryACL property. But: How do I determine from that data whether the "Send As"-permission is explicitly allowed or denied for a trustee? How do I discover this when the

'working, please wait' screen with thread?

感情迁移 提交于 2019-12-03 08:37:46
Perhaps, it is very easy for you, but I am hard working on a project (for educational purposes) that is querying adsi with TADSISearch component, for several days. I'm trying to show a 'Working, Please wait..' splash screen with a man worker animated gif on Form2 while TADSISearch is searching the Active Directory. Although i tried every possibilities according to me, but i couldn't succeed. I tried to use TADSISearch in a thread, but thread is terminating before ADSIsearch finishes. I think TADSISearch is not thread safe. What do you think? Also, another way that I created Form2 and used a

Full name rather than the domain id in User.Identity.Name

↘锁芯ラ 提交于 2019-12-03 04:59:42
问题 The User.Identity.Name property returns the domain login id. Which class/property exposes the actual user name? For user "John Doe" who logs into the web application supplying my_domain\jdoe **User.Identity.Name -** Returns : *my_domain\jdoe* **System.Environment.UserName** Returns: *jdoe* Which class/property returns? ... "John Doe" 回答1: If you are thinking Active Directory, you'll need to find the UserPrincipal that corresponds to the given samAccountName and get the DisplayName property

Full name rather than the domain id in User.Identity.Name

和自甴很熟 提交于 2019-12-02 19:21:25
The User.Identity.Name property returns the domain login id. Which class/property exposes the actual user name? For user "John Doe" who logs into the web application supplying my_domain\jdoe **User.Identity.Name -** Returns : *my_domain\jdoe* **System.Environment.UserName** Returns: *jdoe* Which class/property returns? ... "John Doe" If you are thinking Active Directory, you'll need to find the UserPrincipal that corresponds to the given samAccountName and get the DisplayName property from it. Note that it may not be set. string fullName = null; using (PrincipalContext context = new