c# - LDAP connection only works on localhost -
i have login page verifies credentials active directory , redirects next page. when run locally works perfect, when put out on our webserver gives error trying create group principal: (system.directoryservices.directoryservicescomexception (0x80072020))
i need find out why work on 1 , not other. input appreciated.
principalcontext ctx = new principalcontext(contexttype.domain, "domain.com"); groupprincipal grp = groupprincipal.findbyidentity(ctx, identitytype.name, "building webmasters"); userprincipal = userprincipal.findbyidentity(ctx, identitytype.samaccountname, txtusername.value); bool auth = ctx.validatecredentials(txtusername.value, txtpassword.value); bool groupauth = grp.members.contains(up);
i figured out throwing error on creating user principal. changed grab group principal , contains overload can pass in username form. worked me.
bool auth = ctx.validatecredentials(txtusername.value, txtpassword.value); bool groupauth = grp.members.contains(ctx, identitytype.samaccountname, txtusername.value); bool adminauth = admingrp.members.contains(ctx, identitytype.samaccountname, txtusername.value);
Comments
Post a Comment