salvatore imparato
asked on
Check if user is in Group (ldap adsi WIN NT)
I know:
Name of server is DIP
Name of Group is Farm_group
I need a page with code in ASP classic NO NET!...
create a page in ASP with a box and button.
In the box the user insert the username and after pressing the button controll if the user is in Group on AD Winnt server.
If user is in group goto OK_page.asp if thje user not is in group appera message yopu noet are in "Farm_Group , access denied"
Possible?
Name of server is DIP
Name of Group is Farm_group
I need a page with code in ASP classic NO NET!...
create a page in ASP with a box and button.
In the box the user insert the username and after pressing the button controll if the user is in Group on AD Winnt server.
If user is in group goto OK_page.asp if thje user not is in group appera message yopu noet are in "Farm_Group , access denied"
Possible?
ASKER
Hi ddrudik, tks for link...
But i want to check user in specific group not username and password in winnt ad....
But i want to check user in specific group not username and password in winnt ad....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Peraphs solved 85% with the code here...
1) but ho to read via code the name of user logged and assing to the var sUserName...instead "oi24683"
?????
2) ho to show message in asp page if, after the select case not have success
?????
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor. Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Nuova pagina 1</title>
</head>
<body>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
'http://p2p.wrox.com/topic.asp?TOPIC_ID=7848
Set oNetwork = CreateObject("WScript.Netw ork")
sDomain = "DIP"
sUserName = "OI24683"
'sUserName = oNetwork.UserName
'sUserName = request.servervariables("A UTH_USER")
Set oUser = GetObject("WinNT://" & sDomain & "/" & sUserName & ",user")
For Each oGroup In oUser.Groups
Select Case(oGroup.Name)
Case "InpdapNAXX"
'Response.write("InpdapNAX X")
Response.Redirect("./defau lt.html")
Case "Group B"
'response.write("Yay")
Response.Redirect("A.asp")
Case "Group C"
response.Redirect("Z.asp")
Case "Group D"
Response.redirect("Y.asp")
End Select
Next
%>
</body>
</html>
</form>
1) but ho to read via code the name of user logged and assing to the var sUserName...instead "oi24683"
?????
2) ho to show message in asp page if, after the select case not have success
?????
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Nuova pagina 1</title>
</head>
<body>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
'http://p2p.wrox.com/topic.asp?TOPIC_ID=7848
Set oNetwork = CreateObject("WScript.Netw
sDomain = "DIP"
sUserName = "OI24683"
'sUserName = oNetwork.UserName
'sUserName = request.servervariables("A
Set oUser = GetObject("WinNT://" & sDomain & "/" & sUserName & ",user")
For Each oGroup In oUser.Groups
Select Case(oGroup.Name)
Case "InpdapNAXX"
'Response.write("InpdapNAX
Response.Redirect("./defau
Case "Group B"
'response.write("Yay")
Response.Redirect("A.asp")
Case "Group C"
response.Redirect("Z.asp")
Case "Group D"
Response.redirect("Y.asp")
End Select
Next
%>
</body>
</html>
</form>
1.For request.servervariables("A UTH_USER") to work try unticking "Integrated Windows Authentication" in the same area where you untick anynomous access.
MS seems to think that this is the only solution:
SYMPTOMS
Accessing the Request.ServerVariables("L OGON_USER" ) variable from Active Server Pages (ASP) returns an empty string.
CAUSE
The LOGON_USER variable is not populated if the ASP page is accessed using Allow Anonymous security.
In order for the LOGON_USER variable to be populated, the user must be authenticated using either Basic or NT Challenge/Response security.
2. USe
Case else
response.write "no redirection"
response.end
MS seems to think that this is the only solution:
SYMPTOMS
Accessing the Request.ServerVariables("L
CAUSE
The LOGON_USER variable is not populated if the ASP page is accessed using Allow Anonymous security.
In order for the LOGON_USER variable to be populated, the user must be authenticated using either Basic or NT Challenge/Response security.
2. USe
Case else
response.write "no redirection"
response.end
ASKER
hum........
Now i think.
Is possible to adjust the script in this mode:
insert 2 box in asp page:
username
password
authetnticate the user in domain, if the user with user name and password is authenticate use the filed of username to fill the var susername var....
Wath you think about?
naturally use attention message if user and password not are matched...
Now i think.
Is possible to adjust the script in this mode:
insert 2 box in asp page:
username
password
authetnticate the user in domain, if the user with user name and password is authenticate use the filed of username to fill the var susername var....
Wath you think about?
naturally use attention message if user and password not are matched...
First let me know if the suggestions are working
ASKER
ok ....
But understand my suggestion?
(my english is a napolitan english)
:-)
But understand my suggestion?
(my english is a napolitan english)
:-)
:-)
Ok. Lets try to fix your current problems and then we can always enhance it
Ok. Lets try to fix your current problems and then we can always enhance it
ASKER
nice!!!
Tks for patience.
Pizza are ready for you.
Tks for patience.
Pizza are ready for you.
what about hot wings ?
ASKER
just found tath and it work on my domain:
<form method="post">
<table align="center" border="0" cellpadding="5" cellspacing="0" width="400">
<tr>
<td align="right">Domain:</td>
<td><input type="text" size="30" name="domain" value="" /></td>
</tr>
<tr>
<td align="right">User:</td>
<td><input type="text" size="30" name="username" value="" /></td>
</tr>
<tr>
<td align="right">Password:</t d>
<td><input type="password" size="30" name="password" value="" /></td>
</tr>
<tr>
<td align="center" colspan="2"><input type="submit" value="Login" name="cmdLogin" /></td>
</tr>
</table>
</form>
<%
On Error Resume Next
If Request.Form <> "" Then
strUserName = Request.Form("username")
strPassword = Request.Form("password")
strDomain = Request.Form("domain")
strADsPath = "WinNT://" & strDomain
Set oADsObject = GetObject(strADsPath)
Set oADsNamespace = GetObject("WinNT:")
Set oADsObject = oADsNamespace.OpenDSObject (strADsPat h, strDomain & "\" & strUserName, strPassword, 0)
If Err.Number = 0 Then
Response.Write "<h2>Authenticated</h2>"
Else
Response.Write "<h2>Login Failed</h2>"
End If
End If
%>
<form method="post">
<table align="center" border="0" cellpadding="5" cellspacing="0" width="400">
<tr>
<td align="right">Domain:</td>
<td><input type="text" size="30" name="domain" value="" /></td>
</tr>
<tr>
<td align="right">User:</td>
<td><input type="text" size="30" name="username" value="" /></td>
</tr>
<tr>
<td align="right">Password:</t
<td><input type="password" size="30" name="password" value="" /></td>
</tr>
<tr>
<td align="center" colspan="2"><input type="submit" value="Login" name="cmdLogin" /></td>
</tr>
</table>
</form>
<%
On Error Resume Next
If Request.Form <> "" Then
strUserName = Request.Form("username")
strPassword = Request.Form("password")
strDomain = Request.Form("domain")
strADsPath = "WinNT://" & strDomain
Set oADsObject = GetObject(strADsPath)
Set oADsNamespace = GetObject("WinNT:")
Set oADsObject = oADsNamespace.OpenDSObject
If Err.Number = 0 Then
Response.Write "<h2>Authenticated</h2>"
Else
Response.Write "<h2>Login Failed</h2>"
End If
End If
%>
ASKER
Not uset the box domain i want to isert to the defaul in script....
>>Not uset the box domain i want to isert to the defaul in script....
Sorry didn't understand your 'napolitan english'.Could u explain more
Sorry didn't understand your 'napolitan english'.Could u explain more
ASKER
Hi jitganguly not consider last note: Not uset the box domain i want to isert to the defaul in script....
http://www.codeproject.com/KB/asp/webactivedirlogin.aspx