I am trying to add a new custom attribute in the driectory entry. When i am committing chnages to it. it gives me error "The specified directory service attribute or value does not exis"
I have created a windows service which is accessign the AD.
When there are no new attributes added then no error comes but when a new attribute is added the error above comes.
for setting teh value of teh attribue i am using follwoing function
Public Function SetAttribute(ByVal oEntry As DirectoryEntry, ByVal sAttributeName As String, ByVal objValue As Object) As Boolean
If oEntry.Properties.Contains(sAttributeName) Then
Try
oEntry.Properties(sAttributeName).Value = objValue
bReturn = True
Catch ex As Exception
EventLogHelper.LogFailureAudit("Error Setting Attribute " + sAttributeName + " " + ex.Message + Environment.NewLine + Environment.NewLine + ex.StackTrace)
End Try
END if
End sub
My path of the directory entry is set like this:
Protected Function Z_CreateDirectoryEntry(ByVal sOU As String) As DirectoryEntry
Dim oDirectoryEntry As DirectoryEntry = Nothing
Dim sPath As System.Text.StringBuilder = New System.Text.StringBuilder("")
If m_sServer.Length <> 0 And m_sDomain.Length <> 0 Then
sPath.AppendFormat("LDAP://{0}/", m_sServer)
If sOU.Length <> 0 Then
sPath.Append(sOU)
sPath.AppendFormat(",{0}", m_sDomain)
Else
sPath.Append(m_sDomain)
End If
End If
If sPath.Length <> 0 Then
If m_sUserName <> "" Then
oDirectoryEntry = New DirectoryEntry(sPath.ToString, m_sUserName, m_sPassword)
Else
oDirectoryEntry = New DirectoryEntry(sPath)
End If
If m_iAuthenticationType <> -1 Then
oDirectoryEntry.AuthenticationType = m_iAuthenticationType
End If
Himanshu.Che...
Member
14 Points
3 Posts
DirectoryServices and getting/setting custom Property
Apr 19, 2012 07:29 AM|LINK
Hi
I am trying to add a new custom attribute in the driectory entry. When i am committing chnages to it. it gives me error "The specified directory service attribute or value does not exis"
I have created a windows service which is accessign the AD.
When there are no new attributes added then no error comes but when a new attribute is added the error above comes.
for setting teh value of teh attribue i am using follwoing function
Public Function SetAttribute(ByVal oEntry As DirectoryEntry, ByVal sAttributeName As String, ByVal objValue As Object) As Boolean
If oEntry.Properties.Contains(sAttributeName) Then
Try
oEntry.Properties(sAttributeName).Value = objValue
bReturn = True
Catch ex As Exception
EventLogHelper.LogFailureAudit("Error Setting Attribute " + sAttributeName + " " + ex.Message + Environment.NewLine + Environment.NewLine + ex.StackTrace)
End Try
END if
End sub
My path of the directory entry is set like this:
Protected Function Z_CreateDirectoryEntry(ByVal sOU As String) As DirectoryEntry
Dim oDirectoryEntry As DirectoryEntry = Nothing
Dim sPath As System.Text.StringBuilder = New System.Text.StringBuilder("")
If m_sServer.Length <> 0 And m_sDomain.Length <> 0 Then
sPath.AppendFormat("LDAP://{0}/", m_sServer)
If sOU.Length <> 0 Then
sPath.Append(sOU)
sPath.AppendFormat(",{0}", m_sDomain)
Else
sPath.Append(m_sDomain)
End If
End If
If sPath.Length <> 0 Then
If m_sUserName <> "" Then
oDirectoryEntry = New DirectoryEntry(sPath.ToString, m_sUserName, m_sPassword)
Else
oDirectoryEntry = New DirectoryEntry(sPath)
End If
If m_iAuthenticationType <> -1 Then
oDirectoryEntry.AuthenticationType = m_iAuthenticationType
End If
End If
Return oDirectoryEntry
End Function
The path comes something like this
"LDAP://ipaddress of Server/DC=DEV,DC=COM"
Authetication type is delgations
Please assist where it si going wrong.