Hi folks, I have been surfing the web now for almost two days, driving me nuts as I just cant seem to find the answer to my question. So, here I am asking you guys for a breaktrough:
Problem: I want to delete a classRegistration object in Active Directory using PowerShell using alternate credentials!
Below is my code right now;
----------------------------
$strShortDomainName = "corporate_domain_name"
$VSC_DeleteCachedClusterObject = "LDAP://CN=ObjectToDelete,cn=Lastval...ame,DC=com"
$VSC_DeleteCachedAliasDomainObject = New-Object DirectoryServices.DirectoryEntry ($VSC_DeleteCachedClusterObject),($strShortDomainName + "\MyCustomUserAccount"),"MyCustomPassword"
$VSC_DeleteCachedAliasDomainObject = New-Object DirectoryServices.DirectoryEntry ($VSC_DeleteCachedClusterObject)
$VSC_DeleteCachedAliasDomainObject.psbase.authenticationtype = [System.DirectoryServices.AuthenticationTypes]::FastBind
$VSC_DeleteCachedAliasDomainObject.DeleteObject(0)
$VSC_DeleteCachedAliasDomainObject.SetInfo()
----------------------------
Running the code as a more elevated user from the POSH will execute code correctly and delete the object which indicates a permission problem for the "MyCustomUserAccount". However, opening the adsiedit.msc under the context of the "MyCustomUserAccount" will allow me to delete the object which brings me back to square one!
Another question: If you dont connect / bind to the object using the New-Object DirectoryServices.DirectoryEntry way, rather using the [ADSI] provider, can you connect / bind using this method with alternate credentials? I've been looking but could not find anything.
Again, looking for help here! Thanks in advance!