07deb7dbe7dd3884893f7e8fc557e01146deece5
FAQ/windows-active-directory-security.md
| ... | ... | @@ -36,11 +36,31 @@ Or you can also set these settings manually in the web.config file at the root f |
| 36 | 36 | |
| 37 | 37 | ##Use authentication information in the AdHoc security model |
| 38 | 38 | |
| 39 | +**C♯** |
|
| 39 | 40 | ```csharp |
| 41 | +Imports System.Security.Principal; |
|
| 42 | + |
|
| 43 | +/* |
|
| 44 | + implementation code |
|
| 45 | +*/ |
|
| 46 | + |
|
| 40 | 47 | public override void PostLogin() |
| 41 | 48 | { |
| 42 | 49 | WindowsIdentity user = WindowsIdentity.GetCurrent(); |
| 43 | 50 | AdHocSettings.CurrentUserName = user.Name; |
| 44 | 51 | AdHocSettings.CurrentUserIsAdmin = new WindowsPrincipal(user).IsInRole(WindowsBuiltInRole.Administrator); |
| 45 | 52 | } |
| 53 | +``` |
|
| 54 | + |
|
| 55 | +**VB.NET** |
|
| 56 | +```visualbasic |
|
| 57 | +Using System.Security.Principal |
|
| 58 | + |
|
| 59 | +'implementation code |
|
| 60 | + |
|
| 61 | +Public Overrides Sub PostLogin() |
|
| 62 | + Dim user As WindowsIdentity = WindowsIdentity.GetCurrent() |
|
| 63 | + AdHocSettings.CurrentUserName = user.Name |
|
| 64 | + AdHocSettings.CurrentUserIsAdmin = New WindowsPrincipal(user).IsInRole(WindowsBuiltInRole.Administrator) |
|
| 65 | +End Sub |
|
| 46 | 66 | ``` |
| ... | ... | \ No newline at end of file |