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

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] send only checked items


Hi,


I have 20 checkboxes on my page,


I want tht when I click on the send button, only checked checkboxes send to another page.


they will be send to a grid view


actually I have 20 products on the page, these 20 checkboxes check by user to do compare operation


how can I do this?



Can you show your code?  I have a solution but I have to know the fields you are using.  Please include your aspx and code behind page (vb/cs)



How are your currently handling this?


You can grab all of your Checked CheckBox elements within your code-behind (assuming they are CheckBox controls) as follows :


// Get all of your checked checkboxes
List checkedCheckboxes = Controls.Cast().Where(c => c.Checked).ToList();

I'm not sure how you plan on passing these values across or which sections you need of them (such as the values) but this will get you all of the ones that are checked. If you just wanted to store all of the checked values into an array, you could
probably use something like :


// Get the checked values of all of your checkboxes and store them in an array
var checkedValues = Controls.Cast().Where(c => c.Checked).Select(v => v.Text).ToArray();

Any additional code that you could provide would be greatly appreciated.







Rion Williams



You can grab all of your Checked CheckBox elements within your code-behind (assuming they are CheckBox controls) as follows :


// Get all of your checked checkboxes
List checkedCheckboxes = Controls.Cast().Where(c => c.Checked).ToList();




Yes, that is similar to what I was going to recommend Rion :) 



I thought my code will make u confuse tht's why I asked the question totally,


becoz I also got confused by this problem,


assume tht u have some products on the page,


for these products u put checkbox,ok


for compare operation, user checkes desire checkbox


after tht clicks on the compare button


choosed items ID will be send to gridview to another page


(I've made the poviting gridview, so I can't manipulate it manually, checkboxes ID must be send to a string tht will be used as sqlcommand string)


or any solution u think tht is more right.


one more problem is my sql command must be this structure:


select * from cars_gps where name='gps avl02'

name=checkbox ID

if more checkboxes choosed it have to be like this:


select * from cars_gps where name='gps avl02' or name='gps mvt340'

with grabing all in list box will it work?



Well, I'm sure that your code probably won't confuse Rion or me as we have both been in the .net programming field for years.  Try us.



ok :)


 I declare a static variable to save checkboxes ID on it in a static class


Global.cs


public static class Global
{
public static string strSearch = "";
}

index.aspx


20 of this:



GPS AVL02

add to PostBackUrl="~/compare.aspx">compare page


index.aspx.cs


protected void cb_AVL02_CheckedChanged(object sender, EventArgs e)
{
if(cb_AVL02.Checked==true)
{
Global.strSearch = Global.strSearch + cb_AVL02.ID.ToString();

}
}


I have a simple gridview control in compare.aspx


compare.aspx.cs


public void FillGridView(string StrSearch)
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter(StrSearch, con);
DataSet ds = new DataSet();
da.Fill(ds, "car_detector");
GridView1.DataSource = FlipDataSet(ds);
GridView1.DataBind();
con.Close();
}

public DataSet FlipDataSet(DataSet my_DataSet)
{
DataSet ds = new DataSet();
DataTable table = new DataTable();
DataRow r = null;
foreach (DataTable dt in my_DataSet.Tables)
{

for (int i = 0; i <= dt.Rows.Count; i++)// add columns as much as rows count
{
table.Columns.Add(Convert.ToString(i));
}
for (int k = 0; k < dt.Columns.Count; k++)
{
r = table.NewRow();
r[0] = dt.Columns[k].ToString();
for (int j = 1; j <= dt.Rows.Count; j++)
r[j] = dt.Rows[j - 1][k];
table.Rows.Add(r);
}
ds.Tables.Add(table);
}

return ds;
}


I think my way is wrong,coz have to make some more things static,1st I want to know how to transmit checkboxes


if u show me another solution totally I will be thankful


list box also works like this way I think


without noticing to my way, I want to know if u want to do like this work, what way will u choose?


thank u for spending time for my question :)



First, don't use a static class to share the checkboxes. The reason, this is shared among each and every user on the system so everyone will see the exact same copy of it. There are three easy ways to do this.


1) Querystring.

you can concatenate the id's into a seperated string and pass them to another page using a querystring variable, read the string on the destination page and use the string.split() function to split your delimitted string into an array.


2) Session

You could do the same thing with a session, but with a strongly typed List which would make it more convenient to iterate through and more flexible if you need to manipulate it or query it (ie, use linq to re-order it etc.). Only problem with session is
it's unreliable unless you are using a database as the session store since it's stored in memory (ends up going away). 


3) Cookies

Another tried and true method is to just store the list into a cookie for easy reference without working about messing up the querystring or the frailty of cookies.



thank u for solutions.


can u show me a working example with any option u think tht is more easy?


as I know cookies and querystrings are client-side operation and session is server-side


so if my data needs to be secure I have to use session, some operation like internet shoping, right?


then for transmiting checkboxes it dosent matter which option I use, right?


and my another question is can I mix multiple choice of these 3 options?will any problem happen?any restriction?