顯示具有 App_Code 標籤的文章。 顯示所有文章
顯示具有 App_Code 標籤的文章。 顯示所有文章

2014年7月13日 星期日

[RESOLVED] Active Directory update


I have a process for users to update inofrmation in Ad, one of the things I never accounted for was last name change.  I am trying to change the CN but it keeps erroring me out and tried to search for information but have not been able to find anything. 
Does anyone know how to update the CN of an Active Directory account.  It does not like the remaning of the CN, others said this should work but does not seem to work for me.


Here is my code.


 


  myDataTable = New DataTable
myDataTable = getData(sql)

'Build the Cn
cn = myDataTable.Rows(0)(3).ToString() & "\, " & myDataTable.Rows(0)(17).ToString()

If myDataTable(0)(11) <> "" Then
phone = myDataTable(0)(11)
Else
phone = " "
End If

If myDataTable(0)(12) <> "" Then
ip = myDataTable(0)(12)
Else
ip = " "
End If

Try
user.Properties("employeeType").Value = myDataTable(0)(0).ToString()
user.Properties("mail").Value = myDataTable(0)(1).ToString()
user.Properties("displayName").Value = myDataTable(0)(2).ToString()
user.Properties("sn").Value = myDataTable(0)(3).ToString()
user.Properties("personalTitle").Value = myDataTable(0)(4).ToString()
user.Properties("title").Value = myDataTable(0)(5).ToString()
user.Properties("department").Value = myDataTable(0)(6).ToString()
user.Properties("l").Value = myDataTable(0)(7).ToString()
user.Properties("streetAddress").Value = myDataTable(0)(8).ToString()
user.Properties("st").Value = myDataTable(0)(9).ToString()
user.Properties("postalCode").Value = myDataTable(0)(10)
user.Properties("telephoneNumber").Value = phone.ToString()
user.Properties("ipPhone").Value = ip.ToString
user.Properties("physicalDeliveryOfficeName").Value = myDataTable.Rows(0)(13).ToString()
user.Properties("extensionAttribute2").Value = myDataTable.Rows(0)(14).ToString()
user.Properties("comment").Value = myDataTable.Rows(0)(15).ToString()
user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
user.CommitChanges()
'user.Rename("CN=" & cn)
'user.CommitChanges()

Return True
Catch ex As Exception
Return False
End Try

user.Close()
End If
dirEntry.Close()



I don't think you should need the domain here.  Assuming that column 17 is the user name then it would be:


User.Rename("CN=" + myDataTable.Rows(0)(17).ToString())






HI, that is not the domain, it is the last name and then I add some other data to it.  Here is the error I receive.


 


A device attached to the system is not functioning.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.DirectoryServices.DirectoryServicesCOMException: A device attached to the system is not functioning.


Source Error:
Line 320: user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
Line 321: user.CommitChanges()
Line 322: user.Rename("CN=" + cn)
Line 323: 'user.CommitChanges()
Line 324: ' End With

Source File: C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb Line: 322

Stack Trace:


[DirectoryServicesCOMException (0x8007001f): A device attached to the system is not functioning.
]
System.DirectoryServices.DirectoryEntry.MoveTo(DirectoryEntry newParent, String newName) +335
System.DirectoryServices.DirectoryEntry.Rename(String newName) +44
iMACAD.UpdateADUser(String samAccount, Int32 userId) in C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb:322
Admin_MacRequests.lnkSubmit_Click(Object sender, EventArgs e) in C:\inetpub\wwwroot\iMAC\Admin\MacRequests.aspx.vb:366
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +116
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +101
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9528578
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724




Oh....  I have pretty much the same code but I don't have the / in my names.  Perhaps you need to escape it: //  or try a different character.



HI I don't either I thought the / was the escape to get the comma puit in between last and first names.


Doe, John H MN NG FTS



Did you try without it?



found out i can conetacting and extra comma that i was not escaping in my datarow.  Guess I should hve checked the data before starting a fuss.


[RESOLVED] Active Directory update


I have a process for users to update inofrmation in Ad, one of the things I never accounted for was last name change.  I am trying to change the CN but it keeps erroring me out and tried to search for information but have not been able to find anything. 
Does anyone know how to update the CN of an Active Directory account.  It does not like the remaning of the CN, others said this should work but does not seem to work for me.


Here is my code.


 


  myDataTable = New DataTable
myDataTable = getData(sql)

'Build the Cn
cn = myDataTable.Rows(0)(3).ToString() & "\, " & myDataTable.Rows(0)(17).ToString()

If myDataTable(0)(11) <> "" Then
phone = myDataTable(0)(11)
Else
phone = " "
End If

If myDataTable(0)(12) <> "" Then
ip = myDataTable(0)(12)
Else
ip = " "
End If

Try
user.Properties("employeeType").Value = myDataTable(0)(0).ToString()
user.Properties("mail").Value = myDataTable(0)(1).ToString()
user.Properties("displayName").Value = myDataTable(0)(2).ToString()
user.Properties("sn").Value = myDataTable(0)(3).ToString()
user.Properties("personalTitle").Value = myDataTable(0)(4).ToString()
user.Properties("title").Value = myDataTable(0)(5).ToString()
user.Properties("department").Value = myDataTable(0)(6).ToString()
user.Properties("l").Value = myDataTable(0)(7).ToString()
user.Properties("streetAddress").Value = myDataTable(0)(8).ToString()
user.Properties("st").Value = myDataTable(0)(9).ToString()
user.Properties("postalCode").Value = myDataTable(0)(10)
user.Properties("telephoneNumber").Value = phone.ToString()
user.Properties("ipPhone").Value = ip.ToString
user.Properties("physicalDeliveryOfficeName").Value = myDataTable.Rows(0)(13).ToString()
user.Properties("extensionAttribute2").Value = myDataTable.Rows(0)(14).ToString()
user.Properties("comment").Value = myDataTable.Rows(0)(15).ToString()
user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
user.CommitChanges()
'user.Rename("CN=" & cn)
'user.CommitChanges()

Return True
Catch ex As Exception
Return False
End Try

user.Close()
End If
dirEntry.Close()



I don't think you should need the domain here.  Assuming that column 17 is the user name then it would be:


User.Rename("CN=" + myDataTable.Rows(0)(17).ToString())






HI, that is not the domain, it is the last name and then I add some other data to it.  Here is the error I receive.


 


A device attached to the system is not functioning.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.DirectoryServices.DirectoryServicesCOMException: A device attached to the system is not functioning.


Source Error:
Line 320: user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
Line 321: user.CommitChanges()
Line 322: user.Rename("CN=" + cn)
Line 323: 'user.CommitChanges()
Line 324: ' End With

Source File: C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb Line: 322

Stack Trace:


[DirectoryServicesCOMException (0x8007001f): A device attached to the system is not functioning.
]
System.DirectoryServices.DirectoryEntry.MoveTo(DirectoryEntry newParent, String newName) +335
System.DirectoryServices.DirectoryEntry.Rename(String newName) +44
iMACAD.UpdateADUser(String samAccount, Int32 userId) in C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb:322
Admin_MacRequests.lnkSubmit_Click(Object sender, EventArgs e) in C:\inetpub\wwwroot\iMAC\Admin\MacRequests.aspx.vb:366
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +116
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +101
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9528578
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724




Oh....  I have pretty much the same code but I don't have the / in my names.  Perhaps you need to escape it: //  or try a different character.



HI I don't either I thought the / was the escape to get the comma puit in between last and first names.


Doe, John H MN NG FTS



Did you try without it?



found out i can conetacting and extra comma that i was not escaping in my datarow.  Guess I should hve checked the data before starting a fuss.


[RESOLVED] Active Directory update


I have a process for users to update inofrmation in Ad, one of the things I never accounted for was last name change.  I am trying to change the CN but it keeps erroring me out and tried to search for information but have not been able to find anything. 
Does anyone know how to update the CN of an Active Directory account.  It does not like the remaning of the CN, others said this should work but does not seem to work for me.


Here is my code.


 


  myDataTable = New DataTable
myDataTable = getData(sql)

'Build the Cn
cn = myDataTable.Rows(0)(3).ToString() & "\, " & myDataTable.Rows(0)(17).ToString()

If myDataTable(0)(11) <> "" Then
phone = myDataTable(0)(11)
Else
phone = " "
End If

If myDataTable(0)(12) <> "" Then
ip = myDataTable(0)(12)
Else
ip = " "
End If

Try
user.Properties("employeeType").Value = myDataTable(0)(0).ToString()
user.Properties("mail").Value = myDataTable(0)(1).ToString()
user.Properties("displayName").Value = myDataTable(0)(2).ToString()
user.Properties("sn").Value = myDataTable(0)(3).ToString()
user.Properties("personalTitle").Value = myDataTable(0)(4).ToString()
user.Properties("title").Value = myDataTable(0)(5).ToString()
user.Properties("department").Value = myDataTable(0)(6).ToString()
user.Properties("l").Value = myDataTable(0)(7).ToString()
user.Properties("streetAddress").Value = myDataTable(0)(8).ToString()
user.Properties("st").Value = myDataTable(0)(9).ToString()
user.Properties("postalCode").Value = myDataTable(0)(10)
user.Properties("telephoneNumber").Value = phone.ToString()
user.Properties("ipPhone").Value = ip.ToString
user.Properties("physicalDeliveryOfficeName").Value = myDataTable.Rows(0)(13).ToString()
user.Properties("extensionAttribute2").Value = myDataTable.Rows(0)(14).ToString()
user.Properties("comment").Value = myDataTable.Rows(0)(15).ToString()
user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
user.CommitChanges()
'user.Rename("CN=" & cn)
'user.CommitChanges()

Return True
Catch ex As Exception
Return False
End Try

user.Close()
End If
dirEntry.Close()



I don't think you should need the domain here.  Assuming that column 17 is the user name then it would be:


User.Rename("CN=" + myDataTable.Rows(0)(17).ToString())






HI, that is not the domain, it is the last name and then I add some other data to it.  Here is the error I receive.


 


A device attached to the system is not functioning.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.DirectoryServices.DirectoryServicesCOMException: A device attached to the system is not functioning.


Source Error:
Line 320: user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
Line 321: user.CommitChanges()
Line 322: user.Rename("CN=" + cn)
Line 323: 'user.CommitChanges()
Line 324: ' End With

Source File: C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb Line: 322

Stack Trace:


[DirectoryServicesCOMException (0x8007001f): A device attached to the system is not functioning.
]
System.DirectoryServices.DirectoryEntry.MoveTo(DirectoryEntry newParent, String newName) +335
System.DirectoryServices.DirectoryEntry.Rename(String newName) +44
iMACAD.UpdateADUser(String samAccount, Int32 userId) in C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb:322
Admin_MacRequests.lnkSubmit_Click(Object sender, EventArgs e) in C:\inetpub\wwwroot\iMAC\Admin\MacRequests.aspx.vb:366
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +116
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +101
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9528578
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724




Oh....  I have pretty much the same code but I don't have the / in my names.  Perhaps you need to escape it: //  or try a different character.



HI I don't either I thought the / was the escape to get the comma puit in between last and first names.


Doe, John H MN NG FTS



Did you try without it?



found out i can conetacting and extra comma that i was not escaping in my datarow.  Guess I should hve checked the data before starting a fuss.


[RESOLVED] Active Directory update


I have a process for users to update inofrmation in Ad, one of the things I never accounted for was last name change.  I am trying to change the CN but it keeps erroring me out and tried to search for information but have not been able to find anything. 
Does anyone know how to update the CN of an Active Directory account.  It does not like the remaning of the CN, others said this should work but does not seem to work for me.


Here is my code.


 


  myDataTable = New DataTable
myDataTable = getData(sql)

'Build the Cn
cn = myDataTable.Rows(0)(3).ToString() & "\, " & myDataTable.Rows(0)(17).ToString()

If myDataTable(0)(11) <> "" Then
phone = myDataTable(0)(11)
Else
phone = " "
End If

If myDataTable(0)(12) <> "" Then
ip = myDataTable(0)(12)
Else
ip = " "
End If

Try
user.Properties("employeeType").Value = myDataTable(0)(0).ToString()
user.Properties("mail").Value = myDataTable(0)(1).ToString()
user.Properties("displayName").Value = myDataTable(0)(2).ToString()
user.Properties("sn").Value = myDataTable(0)(3).ToString()
user.Properties("personalTitle").Value = myDataTable(0)(4).ToString()
user.Properties("title").Value = myDataTable(0)(5).ToString()
user.Properties("department").Value = myDataTable(0)(6).ToString()
user.Properties("l").Value = myDataTable(0)(7).ToString()
user.Properties("streetAddress").Value = myDataTable(0)(8).ToString()
user.Properties("st").Value = myDataTable(0)(9).ToString()
user.Properties("postalCode").Value = myDataTable(0)(10)
user.Properties("telephoneNumber").Value = phone.ToString()
user.Properties("ipPhone").Value = ip.ToString
user.Properties("physicalDeliveryOfficeName").Value = myDataTable.Rows(0)(13).ToString()
user.Properties("extensionAttribute2").Value = myDataTable.Rows(0)(14).ToString()
user.Properties("comment").Value = myDataTable.Rows(0)(15).ToString()
user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
user.CommitChanges()
'user.Rename("CN=" & cn)
'user.CommitChanges()

Return True
Catch ex As Exception
Return False
End Try

user.Close()
End If
dirEntry.Close()



I don't think you should need the domain here.  Assuming that column 17 is the user name then it would be:


User.Rename("CN=" + myDataTable.Rows(0)(17).ToString())






HI, that is not the domain, it is the last name and then I add some other data to it.  Here is the error I receive.


 


A device attached to the system is not functioning.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.DirectoryServices.DirectoryServicesCOMException: A device attached to the system is not functioning.


Source Error:
Line 320: user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
Line 321: user.CommitChanges()
Line 322: user.Rename("CN=" + cn)
Line 323: 'user.CommitChanges()
Line 324: ' End With

Source File: C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb Line: 322

Stack Trace:


[DirectoryServicesCOMException (0x8007001f): A device attached to the system is not functioning.
]
System.DirectoryServices.DirectoryEntry.MoveTo(DirectoryEntry newParent, String newName) +335
System.DirectoryServices.DirectoryEntry.Rename(String newName) +44
iMACAD.UpdateADUser(String samAccount, Int32 userId) in C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb:322
Admin_MacRequests.lnkSubmit_Click(Object sender, EventArgs e) in C:\inetpub\wwwroot\iMAC\Admin\MacRequests.aspx.vb:366
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +116
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +101
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9528578
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724




Oh....  I have pretty much the same code but I don't have the / in my names.  Perhaps you need to escape it: //  or try a different character.



HI I don't either I thought the / was the escape to get the comma puit in between last and first names.


Doe, John H MN NG FTS



Did you try without it?



found out i can conetacting and extra comma that i was not escaping in my datarow.  Guess I should hve checked the data before starting a fuss.


[RESOLVED] Active Directory update


I have a process for users to update inofrmation in Ad, one of the things I never accounted for was last name change.  I am trying to change the CN but it keeps erroring me out and tried to search for information but have not been able to find anything. 
Does anyone know how to update the CN of an Active Directory account.  It does not like the remaning of the CN, others said this should work but does not seem to work for me.


Here is my code.


 


  myDataTable = New DataTable
myDataTable = getData(sql)

'Build the Cn
cn = myDataTable.Rows(0)(3).ToString() & "\, " & myDataTable.Rows(0)(17).ToString()

If myDataTable(0)(11) <> "" Then
phone = myDataTable(0)(11)
Else
phone = " "
End If

If myDataTable(0)(12) <> "" Then
ip = myDataTable(0)(12)
Else
ip = " "
End If

Try
user.Properties("employeeType").Value = myDataTable(0)(0).ToString()
user.Properties("mail").Value = myDataTable(0)(1).ToString()
user.Properties("displayName").Value = myDataTable(0)(2).ToString()
user.Properties("sn").Value = myDataTable(0)(3).ToString()
user.Properties("personalTitle").Value = myDataTable(0)(4).ToString()
user.Properties("title").Value = myDataTable(0)(5).ToString()
user.Properties("department").Value = myDataTable(0)(6).ToString()
user.Properties("l").Value = myDataTable(0)(7).ToString()
user.Properties("streetAddress").Value = myDataTable(0)(8).ToString()
user.Properties("st").Value = myDataTable(0)(9).ToString()
user.Properties("postalCode").Value = myDataTable(0)(10)
user.Properties("telephoneNumber").Value = phone.ToString()
user.Properties("ipPhone").Value = ip.ToString
user.Properties("physicalDeliveryOfficeName").Value = myDataTable.Rows(0)(13).ToString()
user.Properties("extensionAttribute2").Value = myDataTable.Rows(0)(14).ToString()
user.Properties("comment").Value = myDataTable.Rows(0)(15).ToString()
user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
user.CommitChanges()
'user.Rename("CN=" & cn)
'user.CommitChanges()

Return True
Catch ex As Exception
Return False
End Try

user.Close()
End If
dirEntry.Close()



I don't think you should need the domain here.  Assuming that column 17 is the user name then it would be:


User.Rename("CN=" + myDataTable.Rows(0)(17).ToString())






HI, that is not the domain, it is the last name and then I add some other data to it.  Here is the error I receive.


 


A device attached to the system is not functioning.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.DirectoryServices.DirectoryServicesCOMException: A device attached to the system is not functioning.


Source Error:
Line 320: user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
Line 321: user.CommitChanges()
Line 322: user.Rename("CN=" + cn)
Line 323: 'user.CommitChanges()
Line 324: ' End With

Source File: C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb Line: 322

Stack Trace:


[DirectoryServicesCOMException (0x8007001f): A device attached to the system is not functioning.
]
System.DirectoryServices.DirectoryEntry.MoveTo(DirectoryEntry newParent, String newName) +335
System.DirectoryServices.DirectoryEntry.Rename(String newName) +44
iMACAD.UpdateADUser(String samAccount, Int32 userId) in C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb:322
Admin_MacRequests.lnkSubmit_Click(Object sender, EventArgs e) in C:\inetpub\wwwroot\iMAC\Admin\MacRequests.aspx.vb:366
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +116
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +101
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9528578
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724




Oh....  I have pretty much the same code but I don't have the / in my names.  Perhaps you need to escape it: //  or try a different character.



HI I don't either I thought the / was the escape to get the comma puit in between last and first names.


Doe, John H MN NG FTS



Did you try without it?



found out i can conetacting and extra comma that i was not escaping in my datarow.  Guess I should hve checked the data before starting a fuss.


[RESOLVED] Active Directory update


I have a process for users to update inofrmation in Ad, one of the things I never accounted for was last name change.  I am trying to change the CN but it keeps erroring me out and tried to search for information but have not been able to find anything. 
Does anyone know how to update the CN of an Active Directory account.  It does not like the remaning of the CN, others said this should work but does not seem to work for me.


Here is my code.


 


  myDataTable = New DataTable
myDataTable = getData(sql)

'Build the Cn
cn = myDataTable.Rows(0)(3).ToString() & "\, " & myDataTable.Rows(0)(17).ToString()

If myDataTable(0)(11) <> "" Then
phone = myDataTable(0)(11)
Else
phone = " "
End If

If myDataTable(0)(12) <> "" Then
ip = myDataTable(0)(12)
Else
ip = " "
End If

Try
user.Properties("employeeType").Value = myDataTable(0)(0).ToString()
user.Properties("mail").Value = myDataTable(0)(1).ToString()
user.Properties("displayName").Value = myDataTable(0)(2).ToString()
user.Properties("sn").Value = myDataTable(0)(3).ToString()
user.Properties("personalTitle").Value = myDataTable(0)(4).ToString()
user.Properties("title").Value = myDataTable(0)(5).ToString()
user.Properties("department").Value = myDataTable(0)(6).ToString()
user.Properties("l").Value = myDataTable(0)(7).ToString()
user.Properties("streetAddress").Value = myDataTable(0)(8).ToString()
user.Properties("st").Value = myDataTable(0)(9).ToString()
user.Properties("postalCode").Value = myDataTable(0)(10)
user.Properties("telephoneNumber").Value = phone.ToString()
user.Properties("ipPhone").Value = ip.ToString
user.Properties("physicalDeliveryOfficeName").Value = myDataTable.Rows(0)(13).ToString()
user.Properties("extensionAttribute2").Value = myDataTable.Rows(0)(14).ToString()
user.Properties("comment").Value = myDataTable.Rows(0)(15).ToString()
user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
user.CommitChanges()
'user.Rename("CN=" & cn)
'user.CommitChanges()

Return True
Catch ex As Exception
Return False
End Try

user.Close()
End If
dirEntry.Close()



I don't think you should need the domain here.  Assuming that column 17 is the user name then it would be:


User.Rename("CN=" + myDataTable.Rows(0)(17).ToString())






HI, that is not the domain, it is the last name and then I add some other data to it.  Here is the error I receive.


 


A device attached to the system is not functioning.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.DirectoryServices.DirectoryServicesCOMException: A device attached to the system is not functioning.


Source Error:
Line 320: user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
Line 321: user.CommitChanges()
Line 322: user.Rename("CN=" + cn)
Line 323: 'user.CommitChanges()
Line 324: ' End With

Source File: C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb Line: 322

Stack Trace:


[DirectoryServicesCOMException (0x8007001f): A device attached to the system is not functioning.
]
System.DirectoryServices.DirectoryEntry.MoveTo(DirectoryEntry newParent, String newName) +335
System.DirectoryServices.DirectoryEntry.Rename(String newName) +44
iMACAD.UpdateADUser(String samAccount, Int32 userId) in C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb:322
Admin_MacRequests.lnkSubmit_Click(Object sender, EventArgs e) in C:\inetpub\wwwroot\iMAC\Admin\MacRequests.aspx.vb:366
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +116
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +101
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9528578
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724




Oh....  I have pretty much the same code but I don't have the / in my names.  Perhaps you need to escape it: //  or try a different character.



HI I don't either I thought the / was the escape to get the comma puit in between last and first names.


Doe, John H MN NG FTS



Did you try without it?



found out i can conetacting and extra comma that i was not escaping in my datarow.  Guess I should hve checked the data before starting a fuss.


[RESOLVED] Active Directory update


I have a process for users to update inofrmation in Ad, one of the things I never accounted for was last name change.  I am trying to change the CN but it keeps erroring me out and tried to search for information but have not been able to find anything. 
Does anyone know how to update the CN of an Active Directory account.  It does not like the remaning of the CN, others said this should work but does not seem to work for me.


Here is my code.


 


  myDataTable = New DataTable
myDataTable = getData(sql)

'Build the Cn
cn = myDataTable.Rows(0)(3).ToString() & "\, " & myDataTable.Rows(0)(17).ToString()

If myDataTable(0)(11) <> "" Then
phone = myDataTable(0)(11)
Else
phone = " "
End If

If myDataTable(0)(12) <> "" Then
ip = myDataTable(0)(12)
Else
ip = " "
End If

Try
user.Properties("employeeType").Value = myDataTable(0)(0).ToString()
user.Properties("mail").Value = myDataTable(0)(1).ToString()
user.Properties("displayName").Value = myDataTable(0)(2).ToString()
user.Properties("sn").Value = myDataTable(0)(3).ToString()
user.Properties("personalTitle").Value = myDataTable(0)(4).ToString()
user.Properties("title").Value = myDataTable(0)(5).ToString()
user.Properties("department").Value = myDataTable(0)(6).ToString()
user.Properties("l").Value = myDataTable(0)(7).ToString()
user.Properties("streetAddress").Value = myDataTable(0)(8).ToString()
user.Properties("st").Value = myDataTable(0)(9).ToString()
user.Properties("postalCode").Value = myDataTable(0)(10)
user.Properties("telephoneNumber").Value = phone.ToString()
user.Properties("ipPhone").Value = ip.ToString
user.Properties("physicalDeliveryOfficeName").Value = myDataTable.Rows(0)(13).ToString()
user.Properties("extensionAttribute2").Value = myDataTable.Rows(0)(14).ToString()
user.Properties("comment").Value = myDataTable.Rows(0)(15).ToString()
user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
user.CommitChanges()
'user.Rename("CN=" & cn)
'user.CommitChanges()

Return True
Catch ex As Exception
Return False
End Try

user.Close()
End If
dirEntry.Close()



I don't think you should need the domain here.  Assuming that column 17 is the user name then it would be:


User.Rename("CN=" + myDataTable.Rows(0)(17).ToString())






HI, that is not the domain, it is the last name and then I add some other data to it.  Here is the error I receive.


 


A device attached to the system is not functioning.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.DirectoryServices.DirectoryServicesCOMException: A device attached to the system is not functioning.


Source Error:
Line 320: user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
Line 321: user.CommitChanges()
Line 322: user.Rename("CN=" + cn)
Line 323: 'user.CommitChanges()
Line 324: ' End With

Source File: C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb Line: 322

Stack Trace:


[DirectoryServicesCOMException (0x8007001f): A device attached to the system is not functioning.
]
System.DirectoryServices.DirectoryEntry.MoveTo(DirectoryEntry newParent, String newName) +335
System.DirectoryServices.DirectoryEntry.Rename(String newName) +44
iMACAD.UpdateADUser(String samAccount, Int32 userId) in C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb:322
Admin_MacRequests.lnkSubmit_Click(Object sender, EventArgs e) in C:\inetpub\wwwroot\iMAC\Admin\MacRequests.aspx.vb:366
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +116
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +101
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9528578
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724




Oh....  I have pretty much the same code but I don't have the / in my names.  Perhaps you need to escape it: //  or try a different character.



HI I don't either I thought the / was the escape to get the comma puit in between last and first names.


Doe, John H MN NG FTS



Did you try without it?



found out i can conetacting and extra comma that i was not escaping in my datarow.  Guess I should hve checked the data before starting a fuss.


[RESOLVED] Active Directory update


I have a process for users to update inofrmation in Ad, one of the things I never accounted for was last name change.  I am trying to change the CN but it keeps erroring me out and tried to search for information but have not been able to find anything. 
Does anyone know how to update the CN of an Active Directory account.  It does not like the remaning of the CN, others said this should work but does not seem to work for me.


Here is my code.


 


  myDataTable = New DataTable
myDataTable = getData(sql)

'Build the Cn
cn = myDataTable.Rows(0)(3).ToString() & "\, " & myDataTable.Rows(0)(17).ToString()

If myDataTable(0)(11) <> "" Then
phone = myDataTable(0)(11)
Else
phone = " "
End If

If myDataTable(0)(12) <> "" Then
ip = myDataTable(0)(12)
Else
ip = " "
End If

Try
user.Properties("employeeType").Value = myDataTable(0)(0).ToString()
user.Properties("mail").Value = myDataTable(0)(1).ToString()
user.Properties("displayName").Value = myDataTable(0)(2).ToString()
user.Properties("sn").Value = myDataTable(0)(3).ToString()
user.Properties("personalTitle").Value = myDataTable(0)(4).ToString()
user.Properties("title").Value = myDataTable(0)(5).ToString()
user.Properties("department").Value = myDataTable(0)(6).ToString()
user.Properties("l").Value = myDataTable(0)(7).ToString()
user.Properties("streetAddress").Value = myDataTable(0)(8).ToString()
user.Properties("st").Value = myDataTable(0)(9).ToString()
user.Properties("postalCode").Value = myDataTable(0)(10)
user.Properties("telephoneNumber").Value = phone.ToString()
user.Properties("ipPhone").Value = ip.ToString
user.Properties("physicalDeliveryOfficeName").Value = myDataTable.Rows(0)(13).ToString()
user.Properties("extensionAttribute2").Value = myDataTable.Rows(0)(14).ToString()
user.Properties("comment").Value = myDataTable.Rows(0)(15).ToString()
user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
user.CommitChanges()
'user.Rename("CN=" & cn)
'user.CommitChanges()

Return True
Catch ex As Exception
Return False
End Try

user.Close()
End If
dirEntry.Close()



I don't think you should need the domain here.  Assuming that column 17 is the user name then it would be:


User.Rename("CN=" + myDataTable.Rows(0)(17).ToString())






HI, that is not the domain, it is the last name and then I add some other data to it.  Here is the error I receive.


 


A device attached to the system is not functioning.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.DirectoryServices.DirectoryServicesCOMException: A device attached to the system is not functioning.


Source Error:
Line 320: user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
Line 321: user.CommitChanges()
Line 322: user.Rename("CN=" + cn)
Line 323: 'user.CommitChanges()
Line 324: ' End With

Source File: C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb Line: 322

Stack Trace:


[DirectoryServicesCOMException (0x8007001f): A device attached to the system is not functioning.
]
System.DirectoryServices.DirectoryEntry.MoveTo(DirectoryEntry newParent, String newName) +335
System.DirectoryServices.DirectoryEntry.Rename(String newName) +44
iMACAD.UpdateADUser(String samAccount, Int32 userId) in C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb:322
Admin_MacRequests.lnkSubmit_Click(Object sender, EventArgs e) in C:\inetpub\wwwroot\iMAC\Admin\MacRequests.aspx.vb:366
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +116
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +101
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9528578
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724




Oh....  I have pretty much the same code but I don't have the / in my names.  Perhaps you need to escape it: //  or try a different character.



HI I don't either I thought the / was the escape to get the comma puit in between last and first names.


Doe, John H MN NG FTS



Did you try without it?



found out i can conetacting and extra comma that i was not escaping in my datarow.  Guess I should hve checked the data before starting a fuss.


[RESOLVED] Active Directory update


I have a process for users to update inofrmation in Ad, one of the things I never accounted for was last name change.  I am trying to change the CN but it keeps erroring me out and tried to search for information but have not been able to find anything. 
Does anyone know how to update the CN of an Active Directory account.  It does not like the remaning of the CN, others said this should work but does not seem to work for me.


Here is my code.


 


  myDataTable = New DataTable
myDataTable = getData(sql)

'Build the Cn
cn = myDataTable.Rows(0)(3).ToString() & "\, " & myDataTable.Rows(0)(17).ToString()

If myDataTable(0)(11) <> "" Then
phone = myDataTable(0)(11)
Else
phone = " "
End If

If myDataTable(0)(12) <> "" Then
ip = myDataTable(0)(12)
Else
ip = " "
End If

Try
user.Properties("employeeType").Value = myDataTable(0)(0).ToString()
user.Properties("mail").Value = myDataTable(0)(1).ToString()
user.Properties("displayName").Value = myDataTable(0)(2).ToString()
user.Properties("sn").Value = myDataTable(0)(3).ToString()
user.Properties("personalTitle").Value = myDataTable(0)(4).ToString()
user.Properties("title").Value = myDataTable(0)(5).ToString()
user.Properties("department").Value = myDataTable(0)(6).ToString()
user.Properties("l").Value = myDataTable(0)(7).ToString()
user.Properties("streetAddress").Value = myDataTable(0)(8).ToString()
user.Properties("st").Value = myDataTable(0)(9).ToString()
user.Properties("postalCode").Value = myDataTable(0)(10)
user.Properties("telephoneNumber").Value = phone.ToString()
user.Properties("ipPhone").Value = ip.ToString
user.Properties("physicalDeliveryOfficeName").Value = myDataTable.Rows(0)(13).ToString()
user.Properties("extensionAttribute2").Value = myDataTable.Rows(0)(14).ToString()
user.Properties("comment").Value = myDataTable.Rows(0)(15).ToString()
user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
user.CommitChanges()
'user.Rename("CN=" & cn)
'user.CommitChanges()

Return True
Catch ex As Exception
Return False
End Try

user.Close()
End If
dirEntry.Close()



I don't think you should need the domain here.  Assuming that column 17 is the user name then it would be:


User.Rename("CN=" + myDataTable.Rows(0)(17).ToString())






HI, that is not the domain, it is the last name and then I add some other data to it.  Here is the error I receive.


 


A device attached to the system is not functioning.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.DirectoryServices.DirectoryServicesCOMException: A device attached to the system is not functioning.


Source Error:
Line 320: user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
Line 321: user.CommitChanges()
Line 322: user.Rename("CN=" + cn)
Line 323: 'user.CommitChanges()
Line 324: ' End With

Source File: C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb Line: 322

Stack Trace:


[DirectoryServicesCOMException (0x8007001f): A device attached to the system is not functioning.
]
System.DirectoryServices.DirectoryEntry.MoveTo(DirectoryEntry newParent, String newName) +335
System.DirectoryServices.DirectoryEntry.Rename(String newName) +44
iMACAD.UpdateADUser(String samAccount, Int32 userId) in C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb:322
Admin_MacRequests.lnkSubmit_Click(Object sender, EventArgs e) in C:\inetpub\wwwroot\iMAC\Admin\MacRequests.aspx.vb:366
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +116
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +101
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9528578
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724




Oh....  I have pretty much the same code but I don't have the / in my names.  Perhaps you need to escape it: //  or try a different character.



HI I don't either I thought the / was the escape to get the comma puit in between last and first names.


Doe, John H MN NG FTS



Did you try without it?



found out i can conetacting and extra comma that i was not escaping in my datarow.  Guess I should hve checked the data before starting a fuss.


[RESOLVED] Active Directory update


I have a process for users to update inofrmation in Ad, one of the things I never accounted for was last name change.  I am trying to change the CN but it keeps erroring me out and tried to search for information but have not been able to find anything. 
Does anyone know how to update the CN of an Active Directory account.  It does not like the remaning of the CN, others said this should work but does not seem to work for me.


Here is my code.


 


  myDataTable = New DataTable
myDataTable = getData(sql)

'Build the Cn
cn = myDataTable.Rows(0)(3).ToString() & "\, " & myDataTable.Rows(0)(17).ToString()

If myDataTable(0)(11) <> "" Then
phone = myDataTable(0)(11)
Else
phone = " "
End If

If myDataTable(0)(12) <> "" Then
ip = myDataTable(0)(12)
Else
ip = " "
End If

Try
user.Properties("employeeType").Value = myDataTable(0)(0).ToString()
user.Properties("mail").Value = myDataTable(0)(1).ToString()
user.Properties("displayName").Value = myDataTable(0)(2).ToString()
user.Properties("sn").Value = myDataTable(0)(3).ToString()
user.Properties("personalTitle").Value = myDataTable(0)(4).ToString()
user.Properties("title").Value = myDataTable(0)(5).ToString()
user.Properties("department").Value = myDataTable(0)(6).ToString()
user.Properties("l").Value = myDataTable(0)(7).ToString()
user.Properties("streetAddress").Value = myDataTable(0)(8).ToString()
user.Properties("st").Value = myDataTable(0)(9).ToString()
user.Properties("postalCode").Value = myDataTable(0)(10)
user.Properties("telephoneNumber").Value = phone.ToString()
user.Properties("ipPhone").Value = ip.ToString
user.Properties("physicalDeliveryOfficeName").Value = myDataTable.Rows(0)(13).ToString()
user.Properties("extensionAttribute2").Value = myDataTable.Rows(0)(14).ToString()
user.Properties("comment").Value = myDataTable.Rows(0)(15).ToString()
user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
user.CommitChanges()
'user.Rename("CN=" & cn)
'user.CommitChanges()

Return True
Catch ex As Exception
Return False
End Try

user.Close()
End If
dirEntry.Close()



I don't think you should need the domain here.  Assuming that column 17 is the user name then it would be:


User.Rename("CN=" + myDataTable.Rows(0)(17).ToString())






HI, that is not the domain, it is the last name and then I add some other data to it.  Here is the error I receive.


 


A device attached to the system is not functioning.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.DirectoryServices.DirectoryServicesCOMException: A device attached to the system is not functioning.


Source Error:
Line 320: user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
Line 321: user.CommitChanges()
Line 322: user.Rename("CN=" + cn)
Line 323: 'user.CommitChanges()
Line 324: ' End With

Source File: C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb Line: 322

Stack Trace:


[DirectoryServicesCOMException (0x8007001f): A device attached to the system is not functioning.
]
System.DirectoryServices.DirectoryEntry.MoveTo(DirectoryEntry newParent, String newName) +335
System.DirectoryServices.DirectoryEntry.Rename(String newName) +44
iMACAD.UpdateADUser(String samAccount, Int32 userId) in C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb:322
Admin_MacRequests.lnkSubmit_Click(Object sender, EventArgs e) in C:\inetpub\wwwroot\iMAC\Admin\MacRequests.aspx.vb:366
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +116
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +101
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9528578
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724




Oh....  I have pretty much the same code but I don't have the / in my names.  Perhaps you need to escape it: //  or try a different character.



HI I don't either I thought the / was the escape to get the comma puit in between last and first names.


Doe, John H MN NG FTS



Did you try without it?



found out i can conetacting and extra comma that i was not escaping in my datarow.  Guess I should hve checked the data before starting a fuss.


[RESOLVED] Active Directory update


I have a process for users to update inofrmation in Ad, one of the things I never accounted for was last name change.  I am trying to change the CN but it keeps erroring me out and tried to search for information but have not been able to find anything. 
Does anyone know how to update the CN of an Active Directory account.  It does not like the remaning of the CN, others said this should work but does not seem to work for me.


Here is my code.


 


  myDataTable = New DataTable
myDataTable = getData(sql)

'Build the Cn
cn = myDataTable.Rows(0)(3).ToString() & "\, " & myDataTable.Rows(0)(17).ToString()

If myDataTable(0)(11) <> "" Then
phone = myDataTable(0)(11)
Else
phone = " "
End If

If myDataTable(0)(12) <> "" Then
ip = myDataTable(0)(12)
Else
ip = " "
End If

Try
user.Properties("employeeType").Value = myDataTable(0)(0).ToString()
user.Properties("mail").Value = myDataTable(0)(1).ToString()
user.Properties("displayName").Value = myDataTable(0)(2).ToString()
user.Properties("sn").Value = myDataTable(0)(3).ToString()
user.Properties("personalTitle").Value = myDataTable(0)(4).ToString()
user.Properties("title").Value = myDataTable(0)(5).ToString()
user.Properties("department").Value = myDataTable(0)(6).ToString()
user.Properties("l").Value = myDataTable(0)(7).ToString()
user.Properties("streetAddress").Value = myDataTable(0)(8).ToString()
user.Properties("st").Value = myDataTable(0)(9).ToString()
user.Properties("postalCode").Value = myDataTable(0)(10)
user.Properties("telephoneNumber").Value = phone.ToString()
user.Properties("ipPhone").Value = ip.ToString
user.Properties("physicalDeliveryOfficeName").Value = myDataTable.Rows(0)(13).ToString()
user.Properties("extensionAttribute2").Value = myDataTable.Rows(0)(14).ToString()
user.Properties("comment").Value = myDataTable.Rows(0)(15).ToString()
user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
user.CommitChanges()
'user.Rename("CN=" & cn)
'user.CommitChanges()

Return True
Catch ex As Exception
Return False
End Try

user.Close()
End If
dirEntry.Close()



I don't think you should need the domain here.  Assuming that column 17 is the user name then it would be:


User.Rename("CN=" + myDataTable.Rows(0)(17).ToString())






HI, that is not the domain, it is the last name and then I add some other data to it.  Here is the error I receive.


 


A device attached to the system is not functioning.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.DirectoryServices.DirectoryServicesCOMException: A device attached to the system is not functioning.


Source Error:
Line 320: user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
Line 321: user.CommitChanges()
Line 322: user.Rename("CN=" + cn)
Line 323: 'user.CommitChanges()
Line 324: ' End With

Source File: C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb Line: 322

Stack Trace:


[DirectoryServicesCOMException (0x8007001f): A device attached to the system is not functioning.
]
System.DirectoryServices.DirectoryEntry.MoveTo(DirectoryEntry newParent, String newName) +335
System.DirectoryServices.DirectoryEntry.Rename(String newName) +44
iMACAD.UpdateADUser(String samAccount, Int32 userId) in C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb:322
Admin_MacRequests.lnkSubmit_Click(Object sender, EventArgs e) in C:\inetpub\wwwroot\iMAC\Admin\MacRequests.aspx.vb:366
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +116
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +101
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9528578
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724




Oh....  I have pretty much the same code but I don't have the / in my names.  Perhaps you need to escape it: //  or try a different character.



HI I don't either I thought the / was the escape to get the comma puit in between last and first names.


Doe, John H MN NG FTS



Did you try without it?



found out i can conetacting and extra comma that i was not escaping in my datarow.  Guess I should hve checked the data before starting a fuss.


[RESOLVED] Active Directory update


I have a process for users to update inofrmation in Ad, one of the things I never accounted for was last name change.  I am trying to change the CN but it keeps erroring me out and tried to search for information but have not been able to find anything. 
Does anyone know how to update the CN of an Active Directory account.  It does not like the remaning of the CN, others said this should work but does not seem to work for me.


Here is my code.


 


  myDataTable = New DataTable
myDataTable = getData(sql)

'Build the Cn
cn = myDataTable.Rows(0)(3).ToString() & "\, " & myDataTable.Rows(0)(17).ToString()

If myDataTable(0)(11) <> "" Then
phone = myDataTable(0)(11)
Else
phone = " "
End If

If myDataTable(0)(12) <> "" Then
ip = myDataTable(0)(12)
Else
ip = " "
End If

Try
user.Properties("employeeType").Value = myDataTable(0)(0).ToString()
user.Properties("mail").Value = myDataTable(0)(1).ToString()
user.Properties("displayName").Value = myDataTable(0)(2).ToString()
user.Properties("sn").Value = myDataTable(0)(3).ToString()
user.Properties("personalTitle").Value = myDataTable(0)(4).ToString()
user.Properties("title").Value = myDataTable(0)(5).ToString()
user.Properties("department").Value = myDataTable(0)(6).ToString()
user.Properties("l").Value = myDataTable(0)(7).ToString()
user.Properties("streetAddress").Value = myDataTable(0)(8).ToString()
user.Properties("st").Value = myDataTable(0)(9).ToString()
user.Properties("postalCode").Value = myDataTable(0)(10)
user.Properties("telephoneNumber").Value = phone.ToString()
user.Properties("ipPhone").Value = ip.ToString
user.Properties("physicalDeliveryOfficeName").Value = myDataTable.Rows(0)(13).ToString()
user.Properties("extensionAttribute2").Value = myDataTable.Rows(0)(14).ToString()
user.Properties("comment").Value = myDataTable.Rows(0)(15).ToString()
user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
user.CommitChanges()
'user.Rename("CN=" & cn)
'user.CommitChanges()

Return True
Catch ex As Exception
Return False
End Try

user.Close()
End If
dirEntry.Close()



I don't think you should need the domain here.  Assuming that column 17 is the user name then it would be:


User.Rename("CN=" + myDataTable.Rows(0)(17).ToString())






HI, that is not the domain, it is the last name and then I add some other data to it.  Here is the error I receive.


 


A device attached to the system is not functioning.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.DirectoryServices.DirectoryServicesCOMException: A device attached to the system is not functioning.


Source Error:
Line 320: user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
Line 321: user.CommitChanges()
Line 322: user.Rename("CN=" + cn)
Line 323: 'user.CommitChanges()
Line 324: ' End With

Source File: C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb Line: 322

Stack Trace:


[DirectoryServicesCOMException (0x8007001f): A device attached to the system is not functioning.
]
System.DirectoryServices.DirectoryEntry.MoveTo(DirectoryEntry newParent, String newName) +335
System.DirectoryServices.DirectoryEntry.Rename(String newName) +44
iMACAD.UpdateADUser(String samAccount, Int32 userId) in C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb:322
Admin_MacRequests.lnkSubmit_Click(Object sender, EventArgs e) in C:\inetpub\wwwroot\iMAC\Admin\MacRequests.aspx.vb:366
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +116
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +101
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9528578
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724




Oh....  I have pretty much the same code but I don't have the / in my names.  Perhaps you need to escape it: //  or try a different character.



HI I don't either I thought the / was the escape to get the comma puit in between last and first names.


Doe, John H MN NG FTS



Did you try without it?



found out i can conetacting and extra comma that i was not escaping in my datarow.  Guess I should hve checked the data before starting a fuss.


[RESOLVED] Active Directory update


I have a process for users to update inofrmation in Ad, one of the things I never accounted for was last name change.  I am trying to change the CN but it keeps erroring me out and tried to search for information but have not been able to find anything. 
Does anyone know how to update the CN of an Active Directory account.  It does not like the remaning of the CN, others said this should work but does not seem to work for me.


Here is my code.


 


  myDataTable = New DataTable
myDataTable = getData(sql)

'Build the Cn
cn = myDataTable.Rows(0)(3).ToString() & "\, " & myDataTable.Rows(0)(17).ToString()

If myDataTable(0)(11) <> "" Then
phone = myDataTable(0)(11)
Else
phone = " "
End If

If myDataTable(0)(12) <> "" Then
ip = myDataTable(0)(12)
Else
ip = " "
End If

Try
user.Properties("employeeType").Value = myDataTable(0)(0).ToString()
user.Properties("mail").Value = myDataTable(0)(1).ToString()
user.Properties("displayName").Value = myDataTable(0)(2).ToString()
user.Properties("sn").Value = myDataTable(0)(3).ToString()
user.Properties("personalTitle").Value = myDataTable(0)(4).ToString()
user.Properties("title").Value = myDataTable(0)(5).ToString()
user.Properties("department").Value = myDataTable(0)(6).ToString()
user.Properties("l").Value = myDataTable(0)(7).ToString()
user.Properties("streetAddress").Value = myDataTable(0)(8).ToString()
user.Properties("st").Value = myDataTable(0)(9).ToString()
user.Properties("postalCode").Value = myDataTable(0)(10)
user.Properties("telephoneNumber").Value = phone.ToString()
user.Properties("ipPhone").Value = ip.ToString
user.Properties("physicalDeliveryOfficeName").Value = myDataTable.Rows(0)(13).ToString()
user.Properties("extensionAttribute2").Value = myDataTable.Rows(0)(14).ToString()
user.Properties("comment").Value = myDataTable.Rows(0)(15).ToString()
user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
user.CommitChanges()
'user.Rename("CN=" & cn)
'user.CommitChanges()

Return True
Catch ex As Exception
Return False
End Try

user.Close()
End If
dirEntry.Close()



I don't think you should need the domain here.  Assuming that column 17 is the user name then it would be:


User.Rename("CN=" + myDataTable.Rows(0)(17).ToString())






HI, that is not the domain, it is the last name and then I add some other data to it.  Here is the error I receive.


 


A device attached to the system is not functioning.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.DirectoryServices.DirectoryServicesCOMException: A device attached to the system is not functioning.


Source Error:
Line 320: user.Properties("description").Value = myDataTable.Rows(0)(16).ToString()
Line 321: user.CommitChanges()
Line 322: user.Rename("CN=" + cn)
Line 323: 'user.CommitChanges()
Line 324: ' End With

Source File: C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb Line: 322

Stack Trace:


[DirectoryServicesCOMException (0x8007001f): A device attached to the system is not functioning.
]
System.DirectoryServices.DirectoryEntry.MoveTo(DirectoryEntry newParent, String newName) +335
System.DirectoryServices.DirectoryEntry.Rename(String newName) +44
iMACAD.UpdateADUser(String samAccount, Int32 userId) in C:\inetpub\wwwroot\iMAC\App_Code\iMACAD.vb:322
Admin_MacRequests.lnkSubmit_Click(Object sender, EventArgs e) in C:\inetpub\wwwroot\iMAC\Admin\MacRequests.aspx.vb:366
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +116
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +101
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9528578
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724




Oh....  I have pretty much the same code but I don't have the / in my names.  Perhaps you need to escape it: //  or try a different character.



HI I don't either I thought the / was the escape to get the comma puit in between last and first names.


Doe, John H MN NG FTS



Did you try without it?



found out i can conetacting and extra comma that i was not escaping in my datarow.  Guess I should hve checked the data before starting a fuss.


[RESOLVED] class for defining variables


Hi,


I started reading about reusability of classes (from class folder) for other pages but cannot find out if I can also set up a class for defining variables. I've been searching for about 2 days on the net to no avail.


The problem is that I use the same variables on many sites and have to dim them on every single page. It's time consuming and blows up script as there are about 100 lines for variables per page.


The idea is to set up a class usable for all pages where I can define a function/sub? that I call on every page and variables are preset. Same for smtp server for mail sending, connection strings for db access... I already tried to set up a sub with the
variables but it did not work (class imported on the page in question and sub also recognized by the system)


any hint?


Thanks in advance.


Pascal




hi


you can always do what you are looking for ... its what the OOPS is for .


looks like you are a VB guy. i am a C# guy ... but i will explain you in C# and you can translate this to VB


lets say i have a class called GridHelper ... will help me with some grid display...how i would do is


public class GridHelper
{
public int Columns {get; set;}
public int Rows {get; set;}
public List GetData()
{
//your logic
}
}

the way you will use the class is to instantiate the object n set the properties and call the function u want


GridHelper helper = new GridHelper();
helper.Columns = 10;
helper.Rows = 10;
List data = helper.GetData();

hope you get the idea






You can try with static class. Please refer




@ kashyapa:


I'm not sure as that's not the kind of variables I define. I found many examples like yours on the net where you use some value to compute a result but I rather have:


Dim p as String
Dim m as String
Dim pa5 As String = HttpContext.Current.Request.Form("passwort5")

I even declared a sub but could not use it for other pages:


    Public Sub transen()
land2 = Replace(land2, " ", "")
land2 = Replace(land2, "+", "")
land2 = Replace(land2, "a", "")
land2 = Replace(land2, "b", "")
...
land2 = Replace(land2, ".", "")
End Sub

or maybe I just do something wrong...



@mahedee:


that doesn't help at all as there are no static classes in vb




Ok, I found out for the sub and functions at least: there is a 'Shared' missing



Public Shared Sub transen()
Dim land2 As String
land2 = Replace(land2, " ", "")
land2 = Replace(land2, "+", "")
...
land2 = Replace(land2, "Z", "")
land2 = Replace(land2, "pag", "")
land2 = Replace(land2, ".", "")
End Sub

I'll leave the post as unsolved as I still miss the part about variables which is the main part of the thread.



You have to think in an object-oriented way. If you need access to things on every page, then each page should have built-in access. First thing to remember is an ASP.Net page inherits from System.Web.UI.Page. What if you created another level? You can create
your own custom page class that inherits from System.Web.UI.Page, adds all the properties and methods that your pages will need to work with, then your pages inherit from that class. Everything still works because your new class inherits from System.Web.UI.Page
so all the properties, methods, events will continue to work.


If you have lots of data bits defined for an application, you may also want some of them stored in the appsettings section of the web.config. Your new custom class can create standard properties to then get those settings using a property, which also gives
you the opportunity to easily ensure that the setting exists, and if it doesn't you can pass a default value from the property.



Hi Mark,


where do I put that custom page in my project? In the class folder or the main folder? And then I just define (dim) all variables there and can use them on every page I want without redefining them?



Hi,


So far as I know, we should not put the custom page into the class folder. Please put them into seperate folders.


If we not design private variables in class, we can declare the calss object then we can use the variables of the class object.


Hope my description is clear.


Best Regards,


Michelle Ge



sorry Michelle,


but I do net get the meaning of your 2nd sentence.




Sorry for the delay. If you are using a web application project, you can create any classes pretty much anywhere you want. The compiler will compile all of your classes into the single output dll.


Web site projects are trickier in that they compile based on directories. The App_Code directory though would be the most appropriate I believe (sorry but I haven't worked with website projects since about 2006) as it is compiled first so that it's classes
are available to all other directories and classes.



I put it into the app_code folder and got it to work in a restricted way.



it recognizes some variables if they are set like:



Shared var as String



but although "dimmed" they seem not to work like I expect them to as I have to set them with a value again in the aspx file I want to use them. So in fact I could as well just add the normal line for "dimming" them and forget about the var file as I will
lose one line anyway... :(