I am creating a new OU each time I move user whom have not logged in for a long time and move them to it. I am able to create the OU but then via Vb.net cannot access keep getting perparation error. The 1st is my creation of the New OU and it has the 2
dates of created and delete on. I think it is simply becuase I put in spaces and slashs in the OU becuase I can get ahold of other OU' no no slashes or spaces no problem. Is there switches to through in here to recognize this?
Dim OU As String = "Created on " & Date.Today & " Delete On" & DateAdd(DateInterval.Day, 45, Date.Today)
Public Shared Function CreateOU(ByVal OU As String) As Boolean
Dim oD As DirectoryEntry
Dim oOU As DirectoryEntry
Try
oD = New DirectoryEntry(Disabled, LDAPUser, LDAPPass, DirectoryServices.AuthenticationTypes.Secure)
oOU = oD.Children.Add(String.Format("ou={0}", OU), "OrganizationalUnit")
oOU.CommitChanges()
Return True
Catch ex As Exception
Return False
End Try
End Function
Now getting at it is the problem, disabling the user works fine but then moveing them is the problem as it does not see the New OU.
Public Shared Function Disable(ByVal Username As String, ByVal OU As String) As Boolean
Dim DirEntry As DirectoryEntry = New DirectoryEntry(OUUsers, LDAPUser, LDAPPass, DirectoryServices.AuthenticationTypes.Secure)
Dim oSearcher As DirectorySearcher = New DirectorySearcher(DirEntry)
Dim result As SearchResult
Dim DisabledOu As String = "LDAP://myLdap/ou=" & OU & ",RestLdap"
oSearcher.Filter = String.Format("(sAMAccountName={0})", Username)
result = oSearcher.FindOne
If Not result Is Nothing Then
Dim user As New DirectoryEntry(result.Path, LDAPUser, LDAPPass, DirectoryServices.AuthenticationTypes.Secure)
'Disable the Account
user.Properties("userAccountControl").Value = 514
user.CommitChanges()
'Move to the New Disabled OU
user.MoveTo(New DirectoryEntry(DisabledOu, LDAPUser, LDAPPass, DirectoryServices.AuthenticationTypes.Secure))
user.CommitChanges()
Return True
Else
Return False
End If
DirEntry.Close()
End Function
Member
77 Points
404 Posts
Cannot access Active Directroy Ou after Creation
Sep 16, 2013 10:11 AM|kldeutsch|LINK
I am creating a new OU each time I move user whom have not logged in for a long time and move them to it. I am able to create the OU but then via Vb.net cannot access keep getting perparation error. The 1st is my creation of the New OU and it has the 2 dates of created and delete on. I think it is simply becuase I put in spaces and slashs in the OU becuase I can get ahold of other OU' no no slashes or spaces no problem. Is there switches to through in here to recognize this?
Now getting at it is the problem, disabling the user works fine but then moveing them is the problem as it does not see the New OU.
Member
680 Points
279 Posts
Re: Cannot access Active Directroy Ou after Creation
Sep 17, 2013 05:54 AM|Tear09|LINK
Hi,
Some links may benefit you:
http://social.technet.microsoft.com/wiki/contents/articles/12582.ad-rms-console-you-cannot-access-the-ad-rms-administration-service-at-this-time.aspx
http://www.myotherpcisacloud.com/post/2013/05/20/Active-Directory-List-Object-Mode.aspx
Thanks