EDN Admin
Well-known member
Hi
Fairly new to .Net programming and currently working in VB only. I have a small application that creates users in the AD. It adds the users fine, and creates them a home directory. My problem is with granting the user permission to the home directory and is two fold
Firstly the code detailed below adds the user to the folder, but because the account is newly created it displays as the SID rather than the name, not such a big deal, but sometimes the code fails as the replication has not caught up and the user isnt found.
I beleive the answer here is to use the SID rather than the users name to add permissions, however I am not sure how to retrieve and store this when the account is created using directory services.
Secondly and more frustrating is that once the user is added to the folder ACL their permissions are all blank.
Does anyone have examples of how to fix this
<div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white
<table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0>
<colgroup>
<col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap
<tbody>
<tr>
<td><font style="font-size:11px Try </font></td></tr>
<tr>
<td style="background-color:#f7f7f7 Dim Dinfo As New DirectoryInfo(Directory) </td></tr>
<tr>
<td> Dim DS As </font><font style="color:red DirectorySecurity</font><font style="font-size:11px = </font><font style="color:blue New</font><font style="font-size:11px DirectorySecurity() </font></td></tr>
<tr>
<td style="background-color:#f7f7f7 Dim Rights As </font><font style="color:red FileSystemRights</font><font style="font-size:11px </font><font style="color:blue FileSystemRights</font><font style="font-size:11px = FileSystemRights.Modify </font></td></tr>
<tr>
<td> Dim ControlType As </font><font style="color:red AccessControlType</font><font style="font-size:11px </font><font style="color:blue AccessControlType</font><font style="font-size:11px = AccessControlType.Allow </font></td></tr>
<tr>
<td style="background-color:#f7f7f7 Dim PropFlag As </font><font style="color:red PropagationFlags</font><font style="font-size:11px </font><font style="color:blue PropagationFlags</font><font style="font-size:11px = PropagationFlags.None </font></td></tr>
<tr>
<td> Dim Inherit As </font><font style="color:red InheritanceFlags</font><font style="font-size:11px </font><font style="color:blue InheritanceFlags</font><font style="font-size:11px = InheritanceFlags.ObjectInherit </font></td></tr>
<tr>
<td style="background-color:#f7f7f7 </td></tr>
<tr>
<td> DS.AddAccessRule(New FileSystemAccessRule(Account, Rights, Inherit, PropFlag, ControlType)) </td></tr>
<tr>
<td style="background-color:#f7f7f7 Dinfo.SetAccessControl(DS) </td></tr>
<tr>
<td> Catch ex As Exception </td></tr>
<tr>
<td style="background-color:#f7f7f7 el.WriteToErrorLog(ex.Message, ex.StackTrace, "AddFolderSecurity Error", ProcessReqID) </td></tr>
<tr>
<td> Throw ex </td></tr>
<tr>
<td style="background-color:#f7f7f7 End Try </td></tr>
<tr>
<td> End Sub </td></tr></tbody></table>
View the full article
Fairly new to .Net programming and currently working in VB only. I have a small application that creates users in the AD. It adds the users fine, and creates them a home directory. My problem is with granting the user permission to the home directory and is two fold
Firstly the code detailed below adds the user to the folder, but because the account is newly created it displays as the SID rather than the name, not such a big deal, but sometimes the code fails as the replication has not caught up and the user isnt found.
I beleive the answer here is to use the SID rather than the users name to add permissions, however I am not sure how to retrieve and store this when the account is created using directory services.
Secondly and more frustrating is that once the user is added to the folder ACL their permissions are all blank.
Does anyone have examples of how to fix this
<div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white
<table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0>
<colgroup>
<col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap
<tbody>
<tr>
<td><font style="font-size:11px Try </font></td></tr>
<tr>
<td style="background-color:#f7f7f7 Dim Dinfo As New DirectoryInfo(Directory) </td></tr>
<tr>
<td> Dim DS As </font><font style="color:red DirectorySecurity</font><font style="font-size:11px = </font><font style="color:blue New</font><font style="font-size:11px DirectorySecurity() </font></td></tr>
<tr>
<td style="background-color:#f7f7f7 Dim Rights As </font><font style="color:red FileSystemRights</font><font style="font-size:11px </font><font style="color:blue FileSystemRights</font><font style="font-size:11px = FileSystemRights.Modify </font></td></tr>
<tr>
<td> Dim ControlType As </font><font style="color:red AccessControlType</font><font style="font-size:11px </font><font style="color:blue AccessControlType</font><font style="font-size:11px = AccessControlType.Allow </font></td></tr>
<tr>
<td style="background-color:#f7f7f7 Dim PropFlag As </font><font style="color:red PropagationFlags</font><font style="font-size:11px </font><font style="color:blue PropagationFlags</font><font style="font-size:11px = PropagationFlags.None </font></td></tr>
<tr>
<td> Dim Inherit As </font><font style="color:red InheritanceFlags</font><font style="font-size:11px </font><font style="color:blue InheritanceFlags</font><font style="font-size:11px = InheritanceFlags.ObjectInherit </font></td></tr>
<tr>
<td style="background-color:#f7f7f7 </td></tr>
<tr>
<td> DS.AddAccessRule(New FileSystemAccessRule(Account, Rights, Inherit, PropFlag, ControlType)) </td></tr>
<tr>
<td style="background-color:#f7f7f7 Dinfo.SetAccessControl(DS) </td></tr>
<tr>
<td> Catch ex As Exception </td></tr>
<tr>
<td style="background-color:#f7f7f7 el.WriteToErrorLog(ex.Message, ex.StackTrace, "AddFolderSecurity Error", ProcessReqID) </td></tr>
<tr>
<td> Throw ex </td></tr>
<tr>
<td style="background-color:#f7f7f7 End Try </td></tr>
<tr>
<td> End Sub </td></tr></tbody></table>
View the full article