The following code works in VBScript, however, when I move it to ASP it fails on the objUser.Put line with error code of "Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))"
If I replace SAPNum with "101" on that line, it works. (e.g. objUser.Put("employeeNumber", "101"). Any ideas???? (Eventually, the SAPNum will come from a user input text box, so that's why I need to variable method to work.)
Sub SetEmpNum(ByVal strUserDN As String, ByVal strPassword As String, ByVal strUser As String)
Dim openDS, objUser
Const ADS_SECURE_AUTHENTICATION = &H1
Dim SAPNum As String = "101"
openDS = GetObject("LDAP:")
objUser = openDS.OpenDSObject("LDAP://" & Replace(strUserDN, "/", "\/"), strUser, strPassword, ADS_SECURE_AUTHENTICATION)
objUser.Put("employeeNumber", SAPNum)
objUser.SetInfo()
End Sub
Thanks
Chad
The following code works in VBScript, however, when I move it to ASP it fails on the objUser.Put line with error code of "Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))"
If I replace SAPNum with "101" on that line, it works. (e.g. objUser.Put("employeeNumber", "101"). Any ideas???? (Eventually, the SAPNum will come from a user input text box, so that's why I need to variable method to work.)
Sub SetEmpNum(ByVal strUserDN As String, ByVal strPassword As String, ByVal strUser As String)
Dim openDS, objUser
Const ADS_SECURE_AUTHENTICATION = &H1
Dim SAPNum As String = "101"
openDS = GetObject("LDAP:")
objUser = openDS.OpenDSObject("LDAP://" & Replace(strUserDN, "/", "\/"), strUser, strPassword, ADS_SECURE_AUTHENTICATION)
objUser.Put("employeeNumber", SAPNum)
objUser.SetInfo()
End Sub
Thanks
Chad
There are some big difference between VB.NET and VB when creating LDAP accounts. There will be no PUT or .SetInfo. You will assign values to the ldap properties and then call ComittChanges(). See the following link for code samples on VB.NET and LDAP
http://www.codeproject.com/Articles/19689/Working-with-Active-Directory-in-VB-NET
Marked as answer by Dino He - MSFT on Feb 29, 2012 03:12 AM
cpremoe
0 Points
1 Post
Need help writing LDAP attributes
Feb 22, 2012 08:59 PM|LINK
The following code works in VBScript, however, when I move it to ASP it fails on the objUser.Put line with error code of "Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))" If I replace SAPNum with "101" on that line, it works. (e.g. objUser.Put("employeeNumber", "101"). Any ideas???? (Eventually, the SAPNum will come from a user input text box, so that's why I need to variable method to work.) Sub SetEmpNum(ByVal strUserDN As String, ByVal strPassword As String, ByVal strUser As String) Dim openDS, objUser Const ADS_SECURE_AUTHENTICATION = &H1 Dim SAPNum As String = "101" openDS = GetObject("LDAP:") objUser = openDS.OpenDSObject("LDAP://" & Replace(strUserDN, "/", "\/"), strUser, strPassword, ADS_SECURE_AUTHENTICATION) objUser.Put("employeeNumber", SAPNum) objUser.SetInfo() End Sub Thanks Chadgww
Contributor
2143 Points
458 Posts
Re: Need help writing LDAP attributes
Feb 23, 2012 06:46 PM|LINK
There are some big difference between VB.NET and VB when creating LDAP accounts. There will be no PUT or .SetInfo. You will assign values to the ldap properties and then call ComittChanges(). See the following link for code samples on VB.NET and LDAP http://www.codeproject.com/Articles/19689/Working-with-Active-Directory-in-VB-NET