471,319 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

logonuser api

Hi,
i need to use logonuser api in c# for windows 2000.
Logonuser api is working fine in windowsXp,Windows2003 server.in

windows 2000 for running logonuser api we need SE_TCB_NAME

Privilege(act as part of operating system).i need to set the

SE_TCB_NAME Privilege programatically with out restarting the

system for the privilege to take effect.
My program need is to check the username,password provided by the

user matches with windows username,password.Is there any other way

to check windows username,password other than using logonuser
Please help me out to solve the problem

Jan 3 '06 #1
3 8033

<pl**********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi,
i need to use logonuser api in c# for windows 2000.
Logonuser api is working fine in windowsXp,Windows2003 server.in

windows 2000 for running logonuser api we need SE_TCB_NAME

Privilege(act as part of operating system).i need to set the

SE_TCB_NAME Privilege programatically with out restarting the

system for the privilege to take effect.
My program need is to check the username,password provided by the

user matches with windows username,password.Is there any other way

to check windows username,password other than using logonuser
Please help me out to solve the problem


If all you need is credential checking, you can use the
NetUserChangePassword API without changing the actual password.
Note that this may return an error code because of local or domain password
policy constraints!!!.
For instance if the local password policy "Minimum password age" is > 0, the
call will return with an error code 1327, but that means that the
credentials are valid but you can't change the password because of policy
constraints, so be carefull with error checking.
[DllImport("netapi32", CharSet=CharSet.Unicode, SetLastError=true)]
static extern int NetUserChangePassword(
[MarshalAs(UnmanagedType.LPWStr)] string domain,
[MarshalAs(UnmanagedType.LPWStr)] string user,
[MarshalAs(UnmanagedType.LPWStr)] string oldpassword,
[MarshalAs(UnmanagedType.LPWStr)] string newpassword);
// where domain is the domain name or a machine name (eg. local machine name
for local accounts)
int ret = NetUserChangePassword(.....);
if (ret != 0) // if failed
{
}
// success
....

Willy.
Jan 3 '06 #2
Thanks Willy Denoyette for your immediate reply.
I am already using NetUserChangePassword in my program,but i forget to
trap the error 1327.thanks for your valuable information.Is there any
chance for the password corruption if anything goes wrong while
executing NetUserChangePassword call.Is it possible to use some other
services to check windows username,password

Regards,
mani

Willy Denoyette [MVP] wrote:
<pl**********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi,
i need to use logonuser api in c# for windows 2000.
Logonuser api is working fine in windowsXp,Windows2003 server.in

windows 2000 for running logonuser api we need SE_TCB_NAME

Privilege(act as part of operating system).i need to set the

SE_TCB_NAME Privilege programatically with out restarting the

system for the privilege to take effect.
My program need is to check the username,password provided by the

user matches with windows username,password.Is there any other way

to check windows username,password other than using logonuser
Please help me out to solve the problem


If all you need is credential checking, you can use the
NetUserChangePassword API without changing the actual password.
Note that this may return an error code because of local or domain password
policy constraints!!!.
For instance if the local password policy "Minimum password age" is > 0, the
call will return with an error code 1327, but that means that the
credentials are valid but you can't change the password because of policy
constraints, so be carefull with error checking.
[DllImport("netapi32", CharSet=CharSet.Unicode, SetLastError=true)]
static extern int NetUserChangePassword(
[MarshalAs(UnmanagedType.LPWStr)] string domain,
[MarshalAs(UnmanagedType.LPWStr)] string user,
[MarshalAs(UnmanagedType.LPWStr)] string oldpassword,
[MarshalAs(UnmanagedType.LPWStr)] string newpassword);
// where domain is the domain name or a machine name (eg. local machine name
for local accounts)
int ret = NetUserChangePassword(.....);
if (ret != 0) // if failed
{
}
// success
...

Willy.


Jan 3 '06 #3
No framework solution unless you are using v2.0 of the framework.

Willy.
<pl**********@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Thanks Willy Denoyette for your immediate reply.
I am already using NetUserChangePassword in my program,but i forget to
trap the error 1327.thanks for your valuable information.Is there any
chance for the password corruption if anything goes wrong while
executing NetUserChangePassword call.Is it possible to use some other
services to check windows username,password

Regards,
mani

Willy Denoyette [MVP] wrote:
<pl**********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
> Hi,
> i need to use logonuser api in c# for windows 2000.
> Logonuser api is working fine in windowsXp,Windows2003 server.in
>
> windows 2000 for running logonuser api we need SE_TCB_NAME
>
> Privilege(act as part of operating system).i need to set the
>
> SE_TCB_NAME Privilege programatically with out restarting the
>
> system for the privilege to take effect.
> My program need is to check the username,password provided by the
>
> user matches with windows username,password.Is there any other way
>
> to check windows username,password other than using logonuser
> Please help me out to solve the problem
>


If all you need is credential checking, you can use the
NetUserChangePassword API without changing the actual password.
Note that this may return an error code because of local or domain
password
policy constraints!!!.
For instance if the local password policy "Minimum password age" is > 0,
the
call will return with an error code 1327, but that means that the
credentials are valid but you can't change the password because of policy
constraints, so be carefull with error checking.
[DllImport("netapi32", CharSet=CharSet.Unicode, SetLastError=true)]
static extern int NetUserChangePassword(
[MarshalAs(UnmanagedType.LPWStr)] string domain,
[MarshalAs(UnmanagedType.LPWStr)] string user,
[MarshalAs(UnmanagedType.LPWStr)] string oldpassword,
[MarshalAs(UnmanagedType.LPWStr)] string newpassword);
// where domain is the domain name or a machine name (eg. local machine
name
for local accounts)
int ret = NetUserChangePassword(.....);
if (ret != 0) // if failed
{
}
// success
...

Willy.

Jan 3 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Nimi | last post: by
3 posts views Thread by Dan | last post: by
2 posts views Thread by BLiTZWiNG | last post: by
7 posts views Thread by Jason | last post: by
9 posts views Thread by schaf | last post: by
1 post views Thread by Sajid | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.