0
I am developing an ASP.NET C# application and at the moment I am at the login point which is almost finished.
I’m using<authentication mode="Windows"></authentication>
and a code that allows the application to verify that credentials are correct.
I’m just missing the code that restricts permissions to groups.
I would like to be indicated a simple code that allows me to basically assign the permission to enter the application only users who are within the existing AD group.
<configuration>
<system.web>
<authorization>
<allow roles="meudominio\Grupo"/>
<deny users="*"/>
</authorization>
<compilation targetFramework="4.0" debug="true"/>
</system.web>
</configuration>
How do you want to restrict? Each group will have access to a particular module? Or have a group that can access the application?
– Jéf Bueno
Right now I just want to access the application.
– Andre Brandao
But in the future through the roles I think I can manage to restrict to each group a function.
– Andre Brandao
And how do you communicate with Active Directory? With some lib?
– Jéf Bueno
[DllImport("advapi32.dll")]
 public static extern bool LogonUser(string name, string domain, string pass, int logType, int logpv, ref IntPtr pht);
 protected void Button1_Click(object sender, EventArgs e)
 {
 IntPtr th = IntPtr.Zero;
 bool log = LogonUser(txt_name.Text, "meudominio" , txt_pass.Text,2,0, ref th);
 if (log)
– Andre Brandao
Right now I’m using this code
– Andre Brandao